一个基于正则表达式的文件/文件夹路径查找工具
Project description
描述
search_files 是一个基于正则表达式的文件/文件夹路径查找工具,能够查找指定目录下的所有子孙路径,通过正则表达式匹配路径,并返回所有符合条件的文件/文件夹路径。
使用示例
import re
from arts import search_files # 导入用来查找路径的函数
from arts import test_dir # 导入用来测试的目录
# 查找所有.py文件
results = search_files(root_dir=test_dir, pattern=r'\.py$', flags=0)
for x in results:
print(x)
# 查找所有文件名包含'README'的文件, 忽略大小写
results = search_files(root_dir=test_dir, pattern=r'README', flags=re.I)
for x in results:
print(x)
参数解释
search_files
- 用来查找路径的函数。
test_dir
- 本项目自带的一个用来测试查找功能的文件夹,该文件夹内置了一些轻量的文件。
root_dir
- 类型:
str或pathlib.Path - 作用:指定查找的根目录,函数将查找该目录下的所有子孙路径。
pattern
- 类型:
str - 作用:用于匹配路径的正则表达式模式。
- 说明:
- 统一使用
/作为路径分隔符,跨平台兼容。 - 正则表达式语法遵循 Python 标准
re模块规范。
- 统一使用
flags
- 类型:
int - 作用:正则表达式匹配标志,用于修改匹配行为。
- 说明:
- 默认为
0,表示无特殊标志 - 需使用
re模块提供的标志,如 re.S、re.I、re.M - 多标志可通过
|组合
- 默认为
版权声明
Copyright (c) 2026 许灿标
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
arts-2026.2.2.tar.gz
(17.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
arts-2026.2.2-py3-none-any.whl
(31.5 kB
view details)
File details
Details for the file arts-2026.2.2.tar.gz.
File metadata
- Download URL: arts-2026.2.2.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3152e41009cfc49dde068858fd074cd807aeb588439bdd95f7e9933592ba1778
|
|
| MD5 |
2377d3971e106b5d3c1f7c36c81872e0
|
|
| BLAKE2b-256 |
f81a2d7081639a51f66c316ae3a4d2fd13ddb2fae8034f6a6337275a70513cce
|
File details
Details for the file arts-2026.2.2-py3-none-any.whl.
File metadata
- Download URL: arts-2026.2.2-py3-none-any.whl
- Upload date:
- Size: 31.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6e0098579cca73aab2acbfb48ef34ff9b160ab81a64d8d2f801f87f4bb1eae1
|
|
| MD5 |
a01e96e3e9dcc8f714e05564c65fc2cd
|
|
| BLAKE2b-256 |
ebb145e04516985f66cbe702d774a533c77c5b6ad54d4ff84879b5c53d999681
|