1.字符串转换成List
a = ‘Hello World!‘ a_list = list(a) //[‘H‘, ‘e‘, ‘l‘, ‘l‘, ‘o‘, ‘ ‘, ‘W‘, ‘o‘, ‘r‘, ‘l‘, ‘d‘, ‘!‘]
其中a为字符串,a_list为List
2.List转换成字符串
a_list = [‘H‘, ‘e‘, ‘l‘, ‘l‘, ‘o‘, ‘ ‘, ‘W‘, ‘o‘, ‘r‘, ‘l‘, ‘d‘, ‘!‘] a = ‘‘.join(a_list) //‘Hello Horld!‘
其中a_list为List,a为字符串
此外,引号中是字符之间的分割符,如‘,’,‘\t‘等等
原文地址:https://www.cnblogs.com/EdenChanIy/p/9463104.html
时间: 2024-10-10 08:03:25