Skip to main content

Bazi

面向中文用户的 Python 3.11+ 八字排盘库,提供四柱、五行、十神、纳音、关系与流运查询。 也可不创建命盘,直接查阅带出处与适用限度的知识条目。运行时只用标准库及随包数据,不联网。

安装

在已有的 Python、conda 或虚拟环境中安装:

python -m pip install bazi

需要新建环境时,可在文档站选择版本后查看“快速开始”。普通使用不需要测试或文档构建工具。

排第一张盘

下面使用虚构的出生信息,按东八区(UTC+8)公历钟填写;默认入口不自动换算时区。 可在 Python 交互环境中直接运行,也可保存为 UTF-8 脚本后运行;不要命名为 bazi.py,以免遮蔽安装包。

from bazi.bazi import Bazi
from bazi.bazi_chart import BaziChart

chart = BaziChart(Bazi.create('1990-05-17 10:30', 'female'))
print('四柱', ' '.join(map(str, chart.bazi.pillars)))
print('日主', chart.bazi.day_master)
print('年干十神', chart.shishen.year.tiangan)
四柱 庚午 辛巳 壬午 乙巳
日主 壬
年干十神 偏印

四柱依次为年、月、日、时。性别用 female(女)或 male(男);类型从定义模块导入。 默认采用 DAY 精度、celestial 后端和 23:00 换日柱。DAY 只按日期比较节气,出生小时仍用于时柱。 海外当地钟与真太阳时的输入方法,见文档站中对应版本的“配置与时间口径”。

继续使用

从文档站选择发布版阅读;当前源码的说明另见开发版文档。

“快速开始”介绍命盘文本、保存结果和可选的环境准备;其余指南包括“配置与时间口径”“关系与流运”、 “集成开发”和“查阅知识库”,知识目录与 API 参考供随时查阅。

不写 Python 时可使用安装后的 bazi 命令,先运行 bazi chart --help 查看排盘选项,更多用法见站点的“命令行”指南。

知识的来源状态、默认展示和命盘前提分别记录;已核出处不证明条文本身为真或适用于某张命盘。 关系与前提匹配返回结构事实,不预测现实事件。

开发

开发环境和完整检查见贡献指南,升级旧调用见发布与迁移。

贡献与许可

欢迎通过 issue 提交勘误和出处;PR 先开 issue 讨论。

作者自有材料采用 MIT License;第三方材料说明 另列历法数据、引文等权利范围, 不由作者的 MIT 授权重新许可。

Metadata

Release files for bazi 2.6.0

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

Source distribution (sdist)

Source distribution for bazi 2.6.0
File Size Uploaded Provenance Actions
bazi-2.6.0.tar.gz 1.4 MB With provenance Details for bazi-2.6.0.tar.gz

Built distribution (wheel)

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

Total release size: 1.9 MB

Release files / bazi-2.6.0.tar.gz

Download URL bazi-2.6.0.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
4bcdcd8eb11634a301db840db2e8542587e23e7e909496c963fc68d1644776dc
BLAKE2b-256 checksum
How to use checksums
c8cf6b6ef7f9bbd9bdb05ee4bd7aa5be3cfd158d2a953868159cbcdd6e07080b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / bazi-2.6.0-py3-none-any.whl

Download URL bazi-2.6.0-py3-none-any.whl
Size 436.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a9490c53562e1f41e170c6e35c8a1d9c8235eaaab3cc3ac25e6492ef79fc8d5
BLAKE2b-256 checksum
How to use checksums
b0606dde9229af814ca61d5732eff56e018ec23d110b1e25920f42e8509eefab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for bazi 2.6.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bazi-2.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

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