What?
sgtpyutils is python module for common utils.
Install
pip install sgtpyutils
Usage
日志处理
from sgtpyutils.logger import logger
logger.debug('调试')
logger.info('信息')
logger.warning('警告')
时间处理
from sgtpyutils.datetime import DateTime
# 当前时间
print(DateTime()) # 2023-09-19 14:50:43.570560+08:00
# 指定日期
print(DateTime('2023-09-19')) # 2023-09-19 00:00:00+08:00
# 指定时间
print(DateTime('2023-09-19 14:50:43')) # 2023-09-19 14:50:43+08:00
# 指定时间戳
print(DateTime(1695106243000)) # 2023-09-19 14:50:43+08:00
# 指定时间及时区
print(DateTime('2023-09-19T14:50:43+07:00')) # 2023-09-19 14:50:43+07:00
# 计算时间差
print((DateTime('2023-09-20') - '2023-09-19').total_seconds()) # 86400.0
print((DateTime('2023-09-20') - 60 * 1000)) # 2023-09-19 23:59:00+08:00
# 获取相对时间
print(DateTime('2023-09-20').toRelativeTime('2023-09-20 14:23')) # 14小时前
print(DateTime('2023-09-20 10:00:00').toRelativeTime('2023-09-20 10:01:00')) # 1分钟后
print(DateTime('2023-01-20 10:00:00').toRelativeTime()) # xxx年前
Status
Metadata
Release files for sgtpyutils 1.20.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sgtpyutils-1.20.15.tar.gz | 48.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sgtpyutils-1.20.15-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 104.8 kB
Release files / sgtpyutils-1.20.15.tar.gz
| Download URL | sgtpyutils-1.20.15.tar.gz |
|---|---|
| Size | 48.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
946a1e993e6294351a2290b082eaf2fd49418cb585cf9260b9fa18e438219877
|
|
BLAKE2b-256 checksum How to use checksums |
eaa797142034ec7f485fbbad140248490bd05835d07cd5aab388f8f58030a237
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / sgtpyutils-1.20.15-py3-none-any.whl
| Download URL | sgtpyutils-1.20.15-py3-none-any.whl |
|---|---|
| Size | 56.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f3277fc77b209b4b659d333557ffe47a48c3bb115c190ba5755b444c6201d76
|
|
BLAKE2b-256 checksum How to use checksums |
77f3d11bc6b2acdccd8d79fb721e0044f56a6a0ba692825dd0b31c3d682e81ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|