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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sgtpyutils-1.20.15.tar.gz
(48.1 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
File details
Details for the file sgtpyutils-1.20.15.tar.gz.
File metadata
- Download URL: sgtpyutils-1.20.15.tar.gz
- Upload date:
- Size: 48.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
946a1e993e6294351a2290b082eaf2fd49418cb585cf9260b9fa18e438219877
|
|
| MD5 |
ff31002a6ef912b72a49c51d7248a75c
|
|
| BLAKE2b-256 |
eaa797142034ec7f485fbbad140248490bd05835d07cd5aab388f8f58030a237
|
File details
Details for the file sgtpyutils-1.20.15-py3-none-any.whl.
File metadata
- Download URL: sgtpyutils-1.20.15-py3-none-any.whl
- Upload date:
- Size: 56.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f3277fc77b209b4b659d333557ffe47a48c3bb115c190ba5755b444c6201d76
|
|
| MD5 |
681f5851197f9271fd37e12d545b9324
|
|
| BLAKE2b-256 |
77f3d11bc6b2acdccd8d79fb721e0044f56a6a0ba692825dd0b31c3d682e81ea
|