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
原文地址:https://www.cnblogs.com/guxiaobei/p/7739729.html