请有人解释一下为什么 .join() 的行为如下:
input = [1, 0, 5, 3, 4, 12, 19]
a = " ".join(str(input))
print(a)
Run Code Online (Sandbox Code Playgroud)
结果是:
[ 1 , 0 , 5 , 3 , 4 , 1 2 , 1 9 ]
Run Code Online (Sandbox Code Playgroud)
不仅还有一个列表,而且还多了一个空间。怎么会?当我使用 map() 时它可以工作:
a = " ".join(list(map(str, input)))
Run Code Online (Sandbox Code Playgroud)
但我想知道我正在使用的 .join 方法有什么问题。