xm = ['zhang3','li4','wang5','zhao6'] a = ','.join(xm)#用逗号连接列表里的内容 a=' '.join(xm)#用空格连接列表里的内容 xm2 = '' for i in xm: xm2 = xm2 + i +' ' xm2 = ' '.join([str(i) for i in xm]) a = 'zhang3 li4 wang5 zhao6' print(a.split(' '))#按照空格来分开 ['zhang3', 'li4', 'wang5', 'zhao6'] print(a.split(','))#按照逗号来分开 'zhang3,li4,wang5,zhao6'
标签:转换,xm,列表,li4,zhao6,zhang3,wang5,字符串,xm2 From: https://www.cnblogs.com/sangern/p/17361763.html