Loading

序列转换

字符串转换为列表

str1="abc bcd def"
str2=str1.split()
结果:
['abc', 'bcd', 'def']
通过split进行分割产生列表

列表和元组转换为字符串则必须依靠join函数

list1=['abc', 'bcd', 'def']
str1=','.join(list1)
print(str1)
结果:
abc,bcd,def
+++++++++++++++++++++++++
元组与列表类似操作

 

posted @ 2018-01-17 16:03  月夫  阅读(87)  评论(0)    收藏  举报