python列表转换为字符串,


对于非纯字符串组成的列表,需要使用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))


 

相关内容

    暂无相关文章

评论关闭