1. 字符串转列表
str1 = "hi hello world" print(str1.split(" "))
输出:
['hi', 'hello', 'world']
2. 列表转字符串
l = ["hi","hello","world"] print(" ".join(l))
输出:
hi hello world
str1 = "hi hello world" print(str1.split(" "))
输出:
['hi', 'hello', 'world']
l = ["hi","hello","world"] print(" ".join(l))
输出:
hi hello world
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。