用法: os.path.splitext(“文件路径”) 分离文件名与扩展名;默认返回(fname,fextension)元组,可做分片操作
例子:
代码语言:javascript复制import os
path_01='E:STHFoobar2000install.log'
path_02='E:STHFoobar2000'
res_01=os.path.splitext(path_01)
res_02=os.path.splitext(path_02)
print(root_01)
print(root_02)
结果:
代码语言:javascript复制('E:\STH\Foobar2000\install', '.log')
('E:\STH\Foobar2000', '')
Only action can relieve the uneasiness.