码迷,mamicode.com
首页 > 编程语言 > 详细

python 把list中的所有元素串起来变为字符串

时间:2018-01-28 13:50:50      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:for   元素   class   div   font   gpo   log   blog   bsp   

list1=[‘2‘,‘3‘,‘4‘]

s=‘‘.join(list1)
print(s)
‘234‘
 
把元素都变为字符串 
list2=[3,4,5]
list2=[str(i) for i in list2]
 

python 把list中的所有元素串起来变为字符串

标签:for   元素   class   div   font   gpo   log   blog   bsp   

原文地址:https://www.cnblogs.com/beforeluck-shang/p/8370826.html

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