Peter Puff Private Utils - 实用的Python工具库
Project description
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
项目地址
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
ppputils-0.0.3.tar.gz
(12.8 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
File details
Details for the file ppputils-0.0.3.tar.gz.
File metadata
- Download URL: ppputils-0.0.3.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0e8ba79c4f16b8551f4e49dd54c9b63d5df1909ba674b44be76e2b900210f21
|
|
| MD5 |
61b5506ba0d9bd675581e1b3688fdf59
|
|
| BLAKE2b-256 |
fbe3d77d4b77ffa0543d0c1dc5f83d6629fda5bef645961c920f8556672677ec
|
File details
Details for the file ppputils-0.0.3-py3-none-any.whl.
File metadata
- Download URL: ppputils-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a29624bdf333161834347e2fa239d1ab484e454078a8312e0dddcc546c2ea2da
|
|
| MD5 |
0131467c22345f1d05b804642079b963
|
|
| BLAKE2b-256 |
448f5dd21bbb699943d9c2432796cd5aabf914d8f38df1e2c4f50112b31c4948
|