python列表转换为字符串

python学习网 2019-11-29 15:21:05

对于非纯字符串组成的列表,需要使用map(str, 列表)转换,纯字符串组成的列表则不需要转换

list1 = [1, 2, 3, 4, 5]
c = ','.join(map(str,list1))
print(c)
print(type(c))


list2 = ['1', '2', '3', '4', '5']
d = ','.join(list2)
print(d)
print(type(d))


 

阅读(2757) 评论(0)