2020
11-17
11-17
Python list和str互转的实现示例
一、list转字符串命令:''.join(list)其中,引号中是字符之间的分割符,如“,”,“;”,“\t”等等如:list=[1,2,3,4,5]''.join(list)结果即为:12345','.join(list)结果即为:1,2,3,4,5二、字符串转listprintlist('12345')输出:['1','2','3','4','5']printlist(map(int,'12345'))输出:[1,2,3,4,5]str2="123sjhiddhi"list2=str2.split()#orlist2=str2.split("")printlist2['123','sjhid',...
继续阅读 >