【发布时间】:2019-02-21 14:49:28
【问题描述】:
如何打印一个没有括号但上面有引号的数组?
我有:
a = ['1','2','3','4','5']
' '.join(map(str, a))
我收到的结果:
1, 2, 3, 4, 5
预期结果(需要):
'1','2','3','4','5'
(带逗号和引号)
【问题讨论】:
-
但它甚至没有给出你的结果?它给了
'1 2 3 4 5' -
print(', '.join(repr(i) for i in a))即使在字符串中有引号时也会正确引用。
标签: python python-3.x python-2.7 jupyter-notebook