python查找文件夹下所有文件实现代码
2023-06-13 09:14:10 时间
deffind_file_by_pattern(pattern=".*",base=".",circle=True):
"""""查找给定文件夹下面所有"""
re_file=re.compile(pattern)
ifbase==".":
base=os.getcwd()
final_file_list=[]
printbase
cur_list=os.listdir(base)
foritemincur_list:
ifitem==".svn":
continue
full_path=os.path.join(base,item)
iffull_path.endswith(".doc")or\
full_path.endswith(".bmp")or\
full_path.endswith(".wpt")or\
full_path.endswith(".dot"):
continue
#printfull_path
bfile=os.path.isfile(item)
ifos.path.isfile(full_path):
ifre_file.search(full_path):
final_file_list.append(full_path)
else:
final_file_list+=find_file_by_pattern(pattern,full_path)
returnfinal_file_list
相关文章
- Python-基础04-数据类型
- python解压bz2文件命令,在Python中解压缩.bz2文件
- Python 对文件的IO操作
- python表情代码_Python实现表情包的代码实例[通俗易懂]
- python读取pkl_Python 读取文件
- python输出unicode编码_Python以utf8编码读取文件
- python抛出异常写法_零基础学 Python(32):如何抛出和捕获异常?「建议收藏」
- python读取excel文件代码_python怎么加速读取excel
- python-Python与MongoDB数据库-处理MongoDB查询结果
- 网络工程师学Python-27-文件读取
- python通过http下载文件的方法详解编程语言
- 手把手|20行Python代码教你批量将PDF文件转为Word格式(包教包会)
- 革命性技术:Python与MSSQL的携手合作(python和mssql)
- Python文件操作技巧(Fileoperation)实例代码分析
- python调用cmd复制文件代码分享
- Python中文件遍历的两种方法
- Python中使用glob和rmtree删除目录子目录及所有文件的例子
- python使用正则搜索字符串或文件中的浮点数代码实例
- 用python代码做configure文件