python的join()函数

def join(self, iterable): # real signature unknown; restored from __doc__
"""
S.join(iterable) -> str

Return a string which is the concatenation of the strings in the
iterable. The separator between elements is S.
"""

上面是库函数的定义:可以看到join()函数的参数要求是一个可迭代对象,比如说:

1.字符串

2.列表

3.元组

join()函数返回一个字符串,这个字符串是可迭代对象(即它的参数)中各个元素的结合,这个结合是以字符S为分隔符的。

 

from os.path import join
d='/media/dell/D'
e='123.txt'
f=join(d,e)

结果是:

'/media/dell/D/123.txt'
自己会加上反斜杠

 

 

from os.path import join
posted on 2018-12-01 21:06  一杯明月  阅读(1302)  评论(0编辑  收藏  举报