:
In [6]: lis1,lis2=[x[0] for x in my_list],[x[1] for x in my_list]
In [7]: lis1
Out[7]: [1320120000000L, 1320206400000L, 1320292800000L]
In [8]: lis2
Out[8]: [48596281, 48596281, 50447908]
veya operator.itemgetter()
kullanarak:
In [19]: lis1,lis2=map(itemgetter(0),my_list) , map(itemgetter(1),my_list)
In [20]: lis1
Out[20]: [1320120000000L, 1320206400000L, 1320292800000L]
In [21]: lis2
Out[21]: [48596281, 48596281, 50447908]
timeit
karşılaştırmalar:
In [42]: %timeit lis1,lis2=[x[0] for x in my_list],[x[1] for x in my_list] #winner if lists are required
100000 loops, best of 3: 1.72 us per loop
In [43]: %timeit my_list2, my_list1 = zip(*my_list) # winner if you want tuples
1000000 loops, best of 3: 1.62 us per loop
In [44]: %timeit my_list2, my_list1 = map(list, zip(*my_list))
100000 loops, best of 3: 4.58 us per loop
In [45]: %timeit lis1,lis2=map(itemgetter(0),my_list),map(itemgetter(1),my_list)
100000 loops, best of 3: 4.4 us per loop
[piton dokümanlardan] (http: // docs. python.org/2/library/functions. html # zip). 'zip() işlevi ile birlikte * işleci bir listenin açılmasını sağlar ' – kreativitea