Python 编程: 读取路径里的文件名

Опубликовано: 30 Июнь 2026
на канале: CodeBilby
78
0

Python 编程: 读取路径里的文件名

用os (Miscellaneous operating system interfaces) 库里的listdir()方法读取路径里的文件名
用re (Regular Expression) 库里的match()方法定义正则表达式去筛选你想要的文件名

Python programming: get file names from a directory

Use the method listdir() in os (Miscellaneous operating system interfaces) module to read all file names from a directory.
Use the method match() in re (Regular Expression) module to match the file name pattern by using the regular expression.


#python #编程 #programming