python中的join()函数到底是做什么用的?希望详细解答 我市小白啊

来源:百度知道 编辑:UC知道 时间:2024/06/18 04:47:21
RT

就是把一个list中所有的串按照你定义的分隔符连接起来,比如:
list = ['a','b','c']
sep = '|'
join(list,sep)的结果就是a|b|c

>>> import string
>>> help(string.join)
Help on function join in module string:

join(words, sep=' ')
join(list [,sep]) -> string

Return a string composed of the words in list, with
intervening occurrences of sep. The default separator is a
single space.

(joinfields and join are synonymous)

>>>

文档写得很明白了的