代码点读机 / Python / join

join Python · 字符串方法

用字符串当胶水,把可迭代对象粘成一个长字符串。

怎么用

'连接符'.join(可迭代对象)

小例子

print('-'.join(['2026', '08', '27']))

运行结果

2026-08-27

官方文档:https://docs.python.org/zh-cn/3/library/stdtypes.html#string-methods

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Python全部词条