Skip to main content

freight-calculator

快递运费计算器:按重量、距离、加急与会员状态计算运费,提供 Python API 与命令行两种用法。

安装

pip install freight-calculator

计费规则

项目 规则
首重 1kg 以内 10 元
续重 每 1kg 加 2 元(不足 1kg 按 1kg 计)
里程 1000km 内免费,超出部分每 500km 加 3 元
加急 附加 8 元
会员 总额 9 折

作为库使用

from freight_calculator import calc_freight

calc_freight(2, 1200, urgent=True)["total"]   # 23.0
calc_freight(5.6, 3000, urgent=True, member=True)["total"]   # 36.0

calc_freight(weight, distance, urgent=False, member=False) 返回明细字典:

键 含义
billing 计费重量(kg,整数)
first 首重费
step 续重费
extra 超出免费里程的公里数
km 里程费
urgent 加急费
discount 会员折扣
total 应付运费

命令行交互

freight-calc
# 或
python -m freight_calculator

测试

python tests/test_core.py

许可证

MIT

Metadata

Release files for freight-calculator 0.1.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 freight-calculator 0.1.0
File Size Uploaded Provenance Actions
freight_calculator-0.1.0.tar.gz 5.0 kB Without provenance Details for freight_calculator-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for freight-calculator 0.1.0
File Interpreter ABI Platform Actions
freight_calculator-0.1.0-py3-none-any.whl Python 3 none any Details for freight_calculator-0.1.0-py3-none-any.whl

Total release size: 10.7 kB

Release files / freight_calculator-0.1.0.tar.gz

Download URL freight_calculator-0.1.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5702d6e20e9da19f5cc519edf01b68c8ef8fa511655eebf3983be850a0a953ac
BLAKE2b-256 checksum
How to use checksums
afff7ff7ef5ed2ab04c9523a23f28c446f8ba42d9410479902154854f53ae025
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / freight_calculator-0.1.0-py3-none-any.whl

Download URL freight_calculator-0.1.0-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c870e6d03dea5746075f9d0ee16c374cd2fe82b6c47fe438269da93542cb9b16
BLAKE2b-256 checksum
How to use checksums
9f4203a398c16e4766fa49fecad85ed4a8001b8b06f1ec0fdd8d224e796c1097
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for freight-calculator 0.1.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.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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