如何将以下列表
转换为字符串
?
list1= [[1, '1', 1], [2,'2',2], [3,'3',3]]
Result: '1 1 1'
'2 2 2'
'3 3 3'
谢谢
最佳答案
看起来像Python。列表推导式让这一切变得简单:
list1= [[1, '1', 1], [2,'2',2], [3,'3',3]]
outlst = [' '.join([str(c) for c in lst]) for lst in list1]
输出:
['1 1 1', '2 2 2', '3 3 3']
关于python - 将嵌套列表转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/973568/