Skip to main content

ddata

一个简单实用的 Python 工具包,提供了日期处理、日志记录、pandas 配置和密码生成等常用功能。

功能特性

  • 日期工具 (date): 提供常用的日期处理功能,如获取今天/昨天、日期格式化、日期加减等
  • 日志工具 (loggor): 简单易用的日志记录封装
  • Pandas 配置 (pandas): 预配置的 pandas 实例,自动设置显示选项
  • 密码生成 (password): 安全的随机密码生成器

安装

pip install ddata

快速开始

日期工具

from ddata import date

# 获取今天日期
print(date.get_today())  # 例如: 20260605

# 获取昨天日期
print(date.yesterday())  # 例如: 20260604

# 获取当前时间
print(date.now())  # 例如: 2026-06-05 14:30:45.123

# 计算 n 天前/后的日期
print(date.n_day_ago("20260605", 7))  # 20260529
print(date.n_day_later("20260605", 7))  # 20260612

# 日期格式化
print(date.today("%Y-%m-%d"))  # 2026-06-05
print(date.date_2_hyphen_date("20260605"))  # 2026-06-05

# 计时器装饰器
@date.timer
def my_function():
    # 你的代码
    pass

日志工具

from ddata import log

log.info("这是一条信息日志")
log.warn("这是一条警告日志")
log.error("这是一条错误日志")

Pandas 配置

from ddata import pd

# pd 是已经配置好的 pandas 实例,会自动显示所有行列
df = pd.DataFrame(...)  # 直接使用即可
print(df)

密码生成

from ddata.password import generate_random_password

# 生成默认 12 位包含特殊字符的密码
password = generate_random_password()
print(password)

# 生成 16 位不包含特殊字符的密码
password = generate_random_password(16, include_special_chars=False)
print(password)

项目结构

ddata/
├── __init__.py       # 包初始化,导出主要功能
├── date.py           # 日期工具
├── loggor.py         # 日志工具
├── pandas.py         # Pandas 配置
├── password.py       # 密码生成
└── test.py           # 测试模块

开发

# 安装开发依赖
pip install -e ".[dev]"

# 运行测试
pytest

作者

flyphant - 576938286@qq.com

许可证

MIT License

Metadata

Release files for ddata 0.2.4

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

Source distribution (sdist)

Source distribution for ddata 0.2.4
File Size Uploaded Provenance Actions
ddata-0.2.4.tar.gz 5.6 kB Without provenance Details for ddata-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ddata 0.2.4
File Interpreter ABI Platform Actions
ddata-0.2.4-py3-none-any.whl Python 3 none any Details for ddata-0.2.4-py3-none-any.whl

Total release size: 12.0 kB

Release files / ddata-0.2.4.tar.gz

Download URL ddata-0.2.4.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bbbd9cb360da8e5513d948a54489e46ca26f68f58844982b73b8e7b64285383a
BLAKE2b-256 checksum
How to use checksums
df5cbb677d106d059183b714626e2dddc4681544dc069f6eefed586ce2473e29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / ddata-0.2.4-py3-none-any.whl

Download URL ddata-0.2.4-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f501d0192efa5f8e6481531b5226f73c62f7637789c5bb32c89ef805d2cfc37
BLAKE2b-256 checksum
How to use checksums
88a52f9332b11d9acf2f594b0527c2dfbdc51a8746f1c47e4ef9c0b383ca20a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Security for ddata 0.2.4

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.

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