python 列表转化为字符串的两种方式

python 列表转化为字符串的两种方式

(1)方式一

>>> juice=['orange','a','b']
>>> ''.join(juice)
'orangeab'

(2)方式二:

>>> juice=['orange','a','b']
>>> content='%s'*len(juice) % tuple(juice)
>>> print content
orangeab
>>>

参考网址:http://www.openstack.org.cn/bbs/forum.php?mod=viewthread&tid=506

猜你喜欢

转载自hw1287789687.iteye.com/blog/2253173