list转换string

方法1 "".join

若list中为字符型

str = "".join(list)

>>> L=['a','b','c']
>>> S="".join(L)
>>> S
'abc'

若list中为整型

先通过for将整型转换为字符型,然后再通过str = "".join(list)转换

>>> L = [1,2,3]
>>> S = "".join(str(x) for x in L)
>>> S
'123'
posted @ 2019-03-21 22:38  Velscode  阅读(1155)  评论(0编辑  收藏  举报