How to convert list to string

Possible Duplicate:

How to convert list into a string?

How can I convert a list to a string using Python?


By using ''.join

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

Or if the list is of integers, convert the elements before joining them.

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/5444.html

上一篇: 将列表中的所有字符串转换为int

下一篇: 如何将列表转换为字符串