码迷,mamicode.com
首页 > 其他好文 > 详细

列表转字符串

时间:2019-03-03 09:25:16      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:span   pre   输出   nbsp   code   style   col   str1   int   

 

 列表转字符串

l = ["hi","hello","world"]
print(" ".join(l))

输出:
hi hello world
 

字符串转列表

str1 = "hi hello world"
print(str1.split(" "))

输出

[hi, hello, world]

 

 

列表转字符串

标签:span   pre   输出   nbsp   code   style   col   str1   int   

原文地址:https://www.cnblogs.com/sea-stream/p/10463717.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!