python中字符串的拼接

python中字符串的拼接。

1、

>>> test1 = ["aaa","bbb","ccc","ddd","eee"]
>>> test1
['aaa', 'bbb', 'ccc', 'ddd', 'eee']
>>> "-".join(test1)
'aaa-bbb-ccc-ddd-eee'

 

2、join的拼接对象可以是任何可迭代对象

>>> test1 = ("111","222","333","444")
>>> test1
('111', '222', '333', '444')
>>> "~".join(test1)
'111~222~333~444'

 

上一篇:Python-01-enumerate()函数


下一篇:linux ssh信任关系