如何将列表转换为字符串

可能重复:

如何将列表转换为字符串?

我如何使用Python将列表转换为字符串?


通过使用''.join

list1 = ['1', '2', '3']
str1 = ''.join(list1)

或者如果列表是整数,则在加入它们之前转换元素。

list1 = [1, 2, 3]
str1 = ''.join(str(e) for e in list1)

>>> L = [1,2,3]       
>>> " ".join(str(x) for x in L)
'1 2 3'

L = ['L','O','L']
makeitastring = ''.join(map(str, L))
链接地址: http://www.djcxy.com/p/5443.html

上一篇: How to convert list to string

下一篇: Convert a list of characters into a string