ppputils
Peter Puff Private Utils - 实用的Python工具库
功能特性
format_utils - 增强的print功能
- ✅ 自动替换全局print:一次导入,全局生效
- ✅ 带时间戳和文件名行号:自动记录打印位置
- ✅ 支持set_args:自定义参数显示
- ✅ 多种print函数:debug、error、warning等快捷函数
ip_utils - 全球最快获取公网IP
- ✅ 全球CDN优化:使用最快的全球CDN服务
- ✅ 自动过滤私有IP:过滤127.0.0.1等无效IP
- ✅ 多种获取方式:HTTP、DNS、STUN、UPnP等
- ✅ 详细信息支持:获取地理位置、ISP等信息
快速开始
安装
pip install ppputils
使用示例
format_utils - 增强的print
# 简单版本(推荐)
from ppputils import print
print("Hello World")
# 输出: [2026-01-23 14:50:00.123] [example.py:3] Hello World
# 自定义版本(支持set_args)
from ppputils.format_utils import print
print.set_args(user_id=123, request_id="req-001")
print("处理请求")
# 输出: [2026-01-23 14:50:00.123] [example.py:6] [user_id:123] [request_id:req-001] 处理请求
ip_utils - 获取公网IP
from ppputils.ip_utils import get_pub_ip_fast
# 全球最快获取IP(推荐)
ip = get_pub_ip_fast()
print(f"我的公网IP: {ip}")
# 获取详细信息
from ppputils.ip_utils import get_pub_ip_with_detail
details = get_pub_ip_with_detail()
if details:
print(f"IP: {details.get('ip')}")
print(f"位置: {details.get('city')}, {details.get('country')}")
详细文档
更多使用说明请查看 USAGE.md
许可证
MIT License
作者
Peter Puff
项目地址
Release files for ppputils 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ppputils-0.0.3.tar.gz | 12.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ppputils-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:22.0 kB
Release files / ppputils-0.0.3.tar.gz
| Download URL | ppputils-0.0.3.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0e8ba79c4f16b8551f4e49dd54c9b63d5df1909ba674b44be76e2b900210f21
|
|
BLAKE2b-256 checksum How to use checksums |
fbe3d77d4b77ffa0543d0c1dc5f83d6629fda5bef645961c920f8556672677ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / ppputils-0.0.3-py3-none-any.whl
| Download URL | ppputils-0.0.3-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a29624bdf333161834347e2fa239d1ab484e454078a8312e0dddcc546c2ea2da
|
|
BLAKE2b-256 checksum How to use checksums |
448f5dd21bbb699943d9c2432796cd5aabf914d8f38df1e2c4f50112b31c4948
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|