python3 字符串(str)与列表(list)互换
作者:互联网
一:str→list
str1=' penny ' str2=list(str1) print(str2) str3='how are you today' str4=str3.split() print(str4) str5='www.taobao.com' str6=str5.split('.') print(str6)
运行结果:
[' ', 'p', 'e', 'n', 'n', 'y', ' '] ['how', 'are', 'you', 'today'] ['www', 'taobao', 'com']
二:list→str
str22="".join(str2) print(str22) str44=" ".join(str4) print(str44) str66=".".join(str6) print(str66)
运行结果:
penny how are you today www.taobao.com
标签:www,str2,list,str6,str4,str,print,python3 来源: https://www.cnblogs.com/pennyxiaoxiantu/p/11413943.html