python join()函数使用方法

python join()函数使用方法,第1张

python join()函数使用方法

Python join() 方法用于将序列中的元素以指定的字符连接生成一个新的字符串。
(既可以连接列表List,也可以连接元组tuple)

举个例子吧

str1 = '-'
str2 = ''
str3 = '+'
List = ['a', 'b', 'c']
# List = ('a', 'b', 'c')
print(str1.join(List))
print(str2.join(List))
print(str3.join(List))

运行结果

a-b-c
abc
a+b+c

由上我们就了解了join函数的使用方法

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5721227.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-18
下一篇 2022-12-18

发表评论

登录后才能评论

评论列表(0条)

保存