开发者

List Changing In Python

[(946871.62999999884, [303.91000000000003]), (964918.62999999884, [353.75]),  
 (965117.81999999878, [356.98000000000002]), (959944.86999999883, [528.53999999999996])]

I have a list that looks like this. I was wondering if there was any way to remove the minilist, so that it would look like

[(94开发者_JAVA百科6871.62999999884, 303.91000000000003), (964918.62999999884, 353.75),  
 (965117.81999999878, 356.98000000000002), (959944.86999999883, 528.53999999999996)]

Thanks for the help!


Use a list comprehension.

L = [(x, y[0]) for x, y in L]


This should do that:

newList = [(x, y[0]) for x, y in oldList]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜