Skip to main content

一个基于正则表达式的文件/文件夹路径查找工具

Project description

描述

search_files 是一个基于正则表达式的文件/文件夹路径查找工具,能够查找指定目录下的所有子孙路径,通过正则表达式匹配路径,并返回所有符合条件的文件/文件夹路径。

使用示例

import re

from arts import search_files  # 导入用来查找路径的函数

# 查找所有.py文件
results = search_files(root_dir=f"{__file__}/..", pattern=r'\.py$', flags=0)
for x in results:
    print(x)

# 查找所有文件名包含'README'的文件, 忽略大小写
results = search_files(root_dir=f"{__file__}/..", pattern=r'README', flags=re.I)
for x in results:
    print(x)

参数解释

search_files

  • 用来查找路径的函数。

root_dir

  • 类型strpathlib.Path
  • 作用:指定查找的根目录,函数将查找该目录下的所有子孙路径。

pattern

  • 类型str
  • 作用:用于匹配路径的正则表达式模式。
  • 说明
    • 统一使用 / 作为路径分隔符,跨平台兼容。
    • 正则表达式语法遵循 Python 标准 re 模块规范。

flags

  • 类型int
  • 作用:正则表达式匹配标志,用于修改匹配行为。
  • 说明
    • 默认为 0,表示无特殊标志
    • 需使用 re 模块提供的标志,如 re.S、re.I、re.M
    • 多标志可通过 | 组合

版权声明

Copyright (c) 2026 许灿标

Project details


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.4.10.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

arts-2026.4.10-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file arts-2026.4.10.tar.gz.

File metadata

  • Download URL: arts-2026.4.10.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for arts-2026.4.10.tar.gz
Algorithm Hash digest
SHA256 a630ff52bee8cfc77626731302dce2461bbdb3c08bf9985b9636ef26ef9f3fa4
MD5 66815c0cfbfc592f7042eff841f7dd64
BLAKE2b-256 9597cacc8c92e21118464d83bba150f8271a2985a6da4557a2a34031e018ff4b

See more details on using hashes here.

File details

Details for the file arts-2026.4.10-py3-none-any.whl.

File metadata

  • Download URL: arts-2026.4.10-py3-none-any.whl
  • Upload date:
  • Size: 27.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for arts-2026.4.10-py3-none-any.whl
Algorithm Hash digest
SHA256 7d0d9ff4eb841b4cfa3c0a118c2f5c013bed80745488ca793da00b72ac62adf8
MD5 476e0bc14474b2dcc55c33f766117bb6
BLAKE2b-256 fd21506041f6325049d335563f0a8672fb0b704ac17c2c5dd3cc43f7fe18d2ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page