编程语言
首页 > 编程语言> > python中字符串的拼接

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'

 

标签:test1,aaa,python,bbb,333,444,eee,拼接,字符串
来源: https://www.cnblogs.com/liujiaxin2018/p/14725007.html