小木木 发表于 2017-5-4 09:14:48

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
页: [1]
查看完整版本: python 列表转化为字符串的两种方式