os.path.splitext,Path
- os.path.splitext(“文件路径”) 分离文件名与扩展名;默认返回(fname,fextension)元组,可做分片操作
- example:
import os path_01='D:/User/wgy/workplace/data/notMNIST_large.tar.gar' path_02='D:/User/wgy/workplace/data/notMNIST_large' root_01=os.path.splitext(path_01) root_02=os.path.splitext(path_02) print(root_01) print(root_02)
结果:
('D:/User/wgy/workplace/data/notMNIST_large.tar', '.gar')
('D:/User/wgy/workplace/data/notMNIST_large', '')
想要获取后缀即可加上[-1]
Path
https://blog.csdn.net/kittyzc/article/details/106462397
注:单纯方便自己查看