我有一个这样的列表:
list1 = [["A","B","C"],["a","b","c"],["1","2","3"]]
如何将其转换为:
["Aa1","Bb2","Cc3"]
答案 0 :(得分:3)
您可以使用zip
和join
:
list1 = [["A","B","C"],["a","b","c"],["1","2","3"]]
result = [''.join(s) for s in zip(*list1)]
print(result)
输出:
['Aa1', 'Bb2', 'Cc3']
答案 1 :(得分:0)
将list
与map
一起使用,此处的密钥为Transpose list of lists
list(map(''.join,zip(*list1)))
['Aa1', 'Bb2', 'Cc3']