我有一个list
和一个list of list
这样的
>>> list2 = [["1","2","3","4"],["5","6","7","8"],["9","10","11","12"]]
>>> list1 = ["a","b","c"]
我压缩了以上两个列表,以便我可以按索引匹配它们的值索引。
>>> mylist = zip(list1,list2)
>>> mylist
[('a', ['1', '2', '3', '4']), ('b', ['5', '6', '7', '8']), ('c', ['9', '10', '11', '12'])]
现在我尝试使用打印上面的mylist
输出
>>> for item in mylist:
... print item[0]
... print "---".join(item[1])
...
它导致了这个输出,这是我的desired output
.
a
1---2---3---4
b
5---6---7---8
c
9---10---11---12
现在,我的问题是有更多的cleaner and better
方法来实现我想要的输出,或者这是best(short and more readable)
可能的方法。