Skip to main content

zfx

zfx 是一个以中文函数命名为核心风格的 Python 多功能工具包,适合日常脚本、数据整理、文本处理、文件操作、系统辅助、网络请求和自动化任务。

它的目标很直接:

  • 按功能分组
  • 调用方式尽量简单
  • 常用操作尽量开箱即用
  • 让中文语境下写 Python 工具代码更顺手

项目特点

  • 使用中文函数名,查找和理解成本低
  • 模块分类明确,适合在 IDE 中按名称排序后浏览
  • 覆盖从基础数据处理到系统、网络、自动化的一整套常见场景
  • 大量函数采用“一个函数一个文件”的组织方式,便于维护和扩展

当前版本更新

当前版本:v2.0.144

本次主要完善了 文本处理 模块,新增和补充了以下功能:

  • 新增 分割文本_多分隔符、分割文本_按长度、分割文本_按空白、分割文本_按次数
  • 新增 取文本所有出现位置、取指定行范围
  • 新增 取引号内容、取括号内容、取括号内容_批量
  • 新增 取最长行、取最短行、取连续汉字、取连续英文、取连续数字
  • 新增 去除空行、去除连续空行、去除每行首尾空白、去除制表符
  • 新增 去除指定字符、去除数字、去除英文、去除汉字、去除符号
  • 新增 去除重复行、去除重复字符
  • 新增 统一换行符、规范化空白、去除所有空白
  • 完善嵌套括号提取、函数示例和内部功能说明
  • 按源码文件顺序整理 文本处理/__init__.py 的统一导出

完整历史更新记录请查看 CHANGELOG.md。

当前已覆盖的模块方向

  • 基础数据:列表、元组、字典、类型转换、数学、常量
  • 文本相关:文本处理、文本文件、编码、json、html
  • 文件系统:文件、目录、配置文件
  • 时间日期:时间
  • 系统相关:系统、进程、多线程、多进程
  • 网络相关:http、网页协议、公共API
  • 自动化相关:playwright、谷歌填表
  • 数据与通信:mysqlx、邮件IMAP、邮件POP3

安装

pip install zfx

如果你只打算使用其中一部分功能,也可以按需关注这些依赖对应的模块:

  • requests:网络请求、公共 API、部分系统网络功能
  • beautifulsoup4:HTML 提取
  • psutil:进程信息
  • pyperclip:剪贴板
  • pymysql:MySQL 相关功能
  • selenium、pyotp:谷歌填表相关功能
  • playwright:Playwright 自动化相关功能
  • pyinstaller:代码打包为 EXE 的相关功能

快速开始

示例 1:获取当前日期

from zfx.时间 import 取当前日期

print(取当前日期())

示例 2:读取目录下所有文件

from zfx.目录 import 取目录下所有文件

文件列表 = 取目录下所有文件(r"D:\Python源码", 是否递归=False)
print(文件列表)

示例 3:安全获取字典路径中的值

from zfx.字典 import 取值_路径

数据 = {"用户": {"信息": [{"城市": "上海"}]}}
结果 = 取值_路径(数据, "用户.信息.0.城市", 默认值="未找到")
print(结果)

示例 4:进行基础 HTTP 请求

from zfx.http import GET, 取响应文本

响应 = GET("https://httpbin.org/get")
文本 = 取响应文本(响应)
print(文本)

适合的使用场景

  • 写个人常用脚本工具箱
  • 快速处理文本、文件、目录和时间数据
  • 整理接口返回结果或嵌套字典数据
  • 编写自动化脚本和辅助工具
  • 作为中文风格的 Python 学习参考项目

使用建议

  • 在 PyCharm 等 IDE 中导入后,建议按名称排序查看模块
  • 功能较多时,优先从分类目录进入,再查找对应函数
  • 涉及浏览器自动化、数据库、邮件等功能时,请先确认本地环境和依赖已就绪

说明

本项目更偏向“实用工具库”和“个人积累型函数库”的风格,强调的是常见任务的快速完成,而不是统一的大型框架设计。

如果你习惯中文命名、希望快速找到现成函数,zfx 会比较适合你。

免责声明

本项目按“原样”提供。请在理解相关功能用途、运行环境和潜在风险的前提下自行评估并使用,作者不对因使用本项目造成的任何直接或间接损失承担责任。

Metadata

Release files for zfx 2.0.145

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zfx 2.0.145
File Size Uploaded Provenance Actions
zfx-2.0.145.tar.gz 485.1 kB Without provenance Details for zfx-2.0.145.tar.gz

Release files / zfx-2.0.145.tar.gz

Download URL zfx-2.0.145.tar.gz
Size 485.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3b54a17d905b0a3db520f31892884ee83a65c7e1afc873bfdb8cafcca5b9d898
BLAKE2b-256 checksum
How to use checksums
a98388c635e22b0248418d465978a8f855b2392e8e814e292b6b3baf7b07309a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for zfx 2.0.145

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.145 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page