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))


 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM