好的,我有一个文件,里面有一些车的名字,以及它们的年限,像这样排列,但每一辆都是一条新的线:
Ford Focus - 5
Ford Focus - 7
Ford Focus - 3
VW Golf - 2
VW Golf - 6
VW Golf - 1
我试图找到一种方法来对这个进行元组化,但是细节是这样分开的:
[(Ford Focus - 5), (Ford Focus - 7), (Ford Focus - 3), (VW Golf - 2), (VW Golf - 6), (VW Golf - 1)]
谢谢
Tags:
列表理解
for循环
我相信,你真正想要的是一个
(brand, year)
形式的元组列表。如果是这样,那么否则
相关问题 更多 >
编程相关推荐