Python操作工具合集
Project description
Operate Tools
Python操作工具合集
Author: Joker-desire
OSCS
安装
pip3 install operate-tools
# v1.0.5版本对整体进行了重写,对于之前的版本请使用以下方式进行安装
pip3 install operate-tools==1.0.4
功能如下
- 日期操作
- 星期操作
- 时间操作
- 文件操作
- ……
功能说明
时间日期工具-Date
from operate_tools import Date
方法
1. 获取当前日期
Date.now(fmt="%Y-%m-%d %H:%M:%S")
2. 获取前几天的日期
Date.days_before(days=31)
3. 获取后几天的日期
Date.days_after(days=31)
4. 获取昨天的日期
Date.yesterday(fmt="%Y-%m-%d")
5. 获取明天的日期
Date.tomorrow(fmt="%Y-%m-%d")
6. 获取上周的日期
Date.last_week(fmt="%Y-%m-%d")
7. 获取下周的日期
Date.next_week(fmt="%Y-%m-%d")
8. 获取上个月的日期
Date.last_month(fmt="%Y-%m-%d")
9. 获取下个月的日期
Date.next_month(fmt="%Y-%m-%d")
10. 获取开始到结束日期的每一天日期
Date.every_day("2021-01-01", "2021-01-05")
11. 计算时间差
Date.time_difference("2022-03-17 16:15:38", "2022-03-17 16:15:40")
12. 判断当前时间是否在指定时间范围内
Date.is_within_time_range(start="00:00", end="09:00")
13. 时间戳转时间
Date.timestamp_to_time("1626441600000", unit="ms")
Date.timestamp_to_time("1626441600", unit="s")
Date.timestamp_to_time("1626441600000", unit="ms", fmt="%Y-%m-%d")
14. 获取当前星期
Date.now_week()
Date.now_week(lang='zh')
Date.now_week(lang='en')
15. 获取某一日期的星期
Date.week("2023-07-19")
Date.week(date="2023-07-19", lang="zh")
Date.week(date="2023-07-19", lang="en")
文件工具-File
from operate_tools import File
方法
1. 获取文件的编码格式
File.encode("test/file.txt")
2. 编码格式转换
res = File.convert_encode("test/file.txt", "utf-8")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
operate_tools-1.0.6.tar.gz
(5.0 kB
view hashes)
Built Distribution
Close
Hashes for operate_tools-1.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5a87f2b3a303d5e5aa14d0fe724e6205c4ccab6ef87b69b462603d5c8b91b94 |
|
MD5 | 6a8ca0b53d2d0bdc864be2ff4a5ae52d |
|
BLAKE2b-256 | 3515665e2b7441bdefcae5766cd5f026cc9c44a3759220d1e3832c3828c1ca0c |