python os.path.basename()
作者:互联网
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以/结尾,那么就会返回空值
标签:python,data,basename,Desktop,usr,path,os 来源: https://www.cnblogs.com/r1-12king/p/13995148.html