This question already has answers here:
Transpose/Unzip Function (inverse of zip)?
                                
                                    (11个答案)
                                
                        
                        
                            Splitting a nested list into two lists [duplicate]
                                
                                    (3个答案)
                                
                        
                                6年前关闭。
            
                    
我有这个数组:

[160, 177], [162, 169], [163, 169], [166, 173], [166, 176], [166, 177], [169, 176], [169, 177]]

我如何将其拆分为2个单独的数组,使其变为:

[160,162,163,166,166,166,169,169]



[177,169,169,173,176,177,176,177]

最佳答案

这应该做

l = [[160, 177], [162, 169], [163, 169], [166, 173], [166, 176], [166, 177], [169, 176], [169, 177]]
l1, l2 = zip(*l)

关于python - 将一个列表分成两个列表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16152957/

10-09 12:42