>>> import os >>> path = '/Users/beazley/Data/data.csv' >>> # Get the last component of the path >>> os.path.basename(path) 'data.csv' >>> # Join path components together >>> os.path.join('tmp', 'data', os.path.basename(path)) 'tmp/data/data.csv'
起连接作用
扩展路径