Skip to main content

Operate Tools

OSCS Status

Python操作工具合集

Author: Joker-desire

OSCS

OSCS Status

安装

pip3 install operate-tools

# v1.0.5版本对整体进行了重写,对于之前的版本请使用以下方式进行安装
pip3 install operate-tools==1.0.4

功能如下

  1. 日期操作
  2. 星期操作
  3. 时间操作
  4. 文件操作
  5. ……

功能说明

时间日期工具-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")

Release files for operate-tools 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for operate-tools 1.0.6
File Size Uploaded
operate_tools-1.0.6.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for operate-tools 1.0.6
File Interpreter ABI Platform
operate_tools-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / operate_tools-1.0.6.tar.gz

Download URL operate_tools-1.0.6.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
64a8da08a3d025e7347f283bd0b295a356e7e67531f77156ed29c87d8e2688c9
BLAKE2b-256 checksum
How to use checksums
cadef3986845a059df2089b780e3cabfe22e8bc69c44bfcbd27b973a5427fb1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.5

Release files / operate_tools-1.0.6-py3-none-any.whl

Download URL operate_tools-1.0.6-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c5a87f2b3a303d5e5aa14d0fe724e6205c4ccab6ef87b69b462603d5c8b91b94
BLAKE2b-256 checksum
How to use checksums
3515665e2b7441bdefcae5766cd5f026cc9c44a3759220d1e3832c3828c1ca0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.5

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

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