python 基础 列表 字符串转换

1. 字符串转列表

str1 = "hi hello world"
print(str1.split(" "))
输出:
['hi', 'hello', 'world']

 2.字典变换为 list

dict.items()

3. 列表转字符串

l = ["hi","hello","world"]
print(" ".join(l))
输出:
hi hello world
posted @ 2017-10-26 22:02  一只宅男的自我修养  阅读(180)  评论(0编辑  收藏  举报