python路径操作函数os.path.join可以将多个路径拼接到一起生成一个新的路径,拼接过程遵守下面两个规则:
os.path.join(path, *paths)
拼接后的路径
>>> os.path.join('/root', 'sd')
'/root/sd'
>>> os.path.join('/root', 'sd', 'aa')
'/root/sd/aa'
>>> os.path.join('/root', 'sd', '')
'/root/sd/'
>>> os.path.join('/root', '/sd', '')
'/sd/'
>>> os.path.join('/root', 'sd/', '')
'/root/sd/'
>>> os.path.join('/root', 'sd/', 'sd')
'/root/sd/sd'
QQ交流群: 211426309