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'

 

posted @ 2021-05-01 22:56  小鲨鱼2018  阅读(64)  评论(0编辑  收藏  举报