List to String or reverse

2015-09-22  本文已影响0人  土豆K
list1 = ['1', '2', '3']
str1 = ''.join(list1)

‘’ contains the delimiter

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)

Convert string to list:
import string
str = 'abcde'
list = list(str)

上一篇下一篇

猜你喜欢

热点阅读