我根據網上找的——
a
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
b
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
c=zip(a,b)
c
[(0, 9), (1, 8), (2, 7), (3, 6), (4, 5), (5, 4), (6, 3), (7, 2), (8, 1), (9, 0)]
c.sort(key=lambda x:x[1])
c
[(9, 0), (8, 1), (7, 2), (6, 3), (5, 4), (4, 5), (3, 6), (2, 7), (1, 8), (0, 9)]
用vim寫了個python腳本,
我用的是a=c.sort(key=lambda x:x[1])
然後print a
為什麼在linux上運行的結果是None?
sort是對list自身排序的 所以你可以打印print c 而a根本沒獲取數據