A collection of utility tools for Python development
Project description
mtools
一个实用的Python工具集合,提供常用功能的封装,方便在Python项目中使用。
功能特性
- 时间处理:获取当前时间、格式化时间字符串、转换为标准格式
- 路径处理:跨平台路径处理,兼容打包环境
- 数据转换:数字转换工具
安装方法
使用pip安装
pip install mtools
更新
pip install --upgrade mtools
使用uv安装
uv add mtools
使用示例
时间处理
from mtools import get_current_time, format_time_string, convert_to_standard_format
# 获取当前时间
current_time = get_current_time()
print(current_time) # 输出类似: 2023-05-15 14:30:45
# 格式化时间字符串
formatted = format_time_string("2023-05-15T14:30:45", "%Y年%m月%d日 %H:%M:%S")
print(formatted) # 输出: 2023年05月15日 14:30:45
# 转换为标准格式
standard = convert_to_standard_format("15/05/2023 14:30:45")
print(standard) # 输出: 2023-05-15 14:30:45
路径处理
from mtool import get_app_dir, get_resource_path, get_data_directory
# 获取程序目录
program_dir = get_app_dir()
# 获取资源文件路径
resource = get_resource_path("images", "logo.png")
# 获取数据目录
input_dir = get_data_directory("input")
output_dir = get_data_directory("output")
数据转换
from mtools import to_rounded_decimal
# 转换为四舍五入的Decimal
decimal_value = to_rounded_decimal("10.125")
print(decimal_value) # 输出: 10.13
许可证
MIT License
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
mtool-0.1.2.tar.gz
(18.4 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
mtool-0.1.2-py3-none-any.whl
(6.7 kB
view details)
File details
Details for the file mtool-0.1.2.tar.gz.
File metadata
- Download URL: mtool-0.1.2.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbefe8447b0173bf351302213116f52815f5122396574cdee383885461b9361b
|
|
| MD5 |
d747259fa04fdf159b1e05d1ef3bc4ee
|
|
| BLAKE2b-256 |
9967d70e7e19d024c38fc78b35ffa9bb965be12024ed87020328e2d7dfb528a4
|
File details
Details for the file mtool-0.1.2-py3-none-any.whl.
File metadata
- Download URL: mtool-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f811fa830e01c7d96fdef067b0a1b6d8d2e42fa5a1db894cde3f577ef3089fc2
|
|
| MD5 |
cec28c3bd661892d7e2d70916facb68d
|
|
| BLAKE2b-256 |
931aa1901fc30e4b0ab8d5dae186deb1cfa5bdc2d16d2bae3f6d12b753afd487
|