os.path.basename(path): 返回path最后的文件名称
>>> import os >>> path = "usr/linxi/Desktop/data.cvs" >>> os.path.basename(path) 'data.cvs' >>> path = "c:\windows\tools\data.csv" >>> os.path.basename(path) 'data.csv' >>> path = "usr/linxi/Desktop/" >>> os.path.basename(path) ''
从上面可以看出,如果path以/结尾,那么就会返回空值