美文网首页
List to String or reverse

List to String or reverse

作者: 土豆K | 来源:发表于2015-09-22 23:09 被阅读0次
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)

相关文章

网友评论

      本文标题:List to String or reverse

      本文链接:https://www.haomeiwen.com/subject/eypicttx.html