- os.path.splitext()
os.path.splitext(“文件路径”) 分离文件名与扩展名;默认返回(fname,fextension)元组,可做分片操作。
- os.path.basename()
os.path.basename(),返回path最后的文件名。若path以/或\结尾,那么就会返回空值。
【应用】:
- 判断是否为隐藏文件,并做出筛选
import os
if os.path.basename(path)[0] != '.':
#...............
- 获取不带后缀文件名
例如:
(以后遇到类似的再继续总结上来)
A u t h o r : 一 定 能 战 胜 D D L 的 c h i e r Author: 一定能战胜DDL的chier Author:一定能战胜DDL的chier