Skip to main content

A Python data package

Project description

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

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

ddata-0.2.4.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

ddata-0.2.4-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file ddata-0.2.4.tar.gz.

File metadata

  • Download URL: ddata-0.2.4.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for ddata-0.2.4.tar.gz
Algorithm Hash digest
SHA256 bbbd9cb360da8e5513d948a54489e46ca26f68f58844982b73b8e7b64285383a
MD5 c96aaa8a487bcda5ccaa11748aa3070b
BLAKE2b-256 df5cbb677d106d059183b714626e2dddc4681544dc069f6eefed586ce2473e29

See more details on using hashes here.

File details

Details for the file ddata-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: ddata-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for ddata-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4f501d0192efa5f8e6481531b5226f73c62f7637789c5bb32c89ef805d2cfc37
MD5 17a3cca8c4e992d86cfc6e1c6423930b
BLAKE2b-256 88a52f9332b11d9acf2f594b0527c2dfbdc51a8746f1c47e4ef9c0b383ca20a8

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