Skip to main content

Python操作工具合集

Project description

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")

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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

operate_tools-1.0.6-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file operate_tools-1.0.6.tar.gz.

File metadata

  • Download URL: operate_tools-1.0.6.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for operate_tools-1.0.6.tar.gz
Algorithm Hash digest
SHA256 64a8da08a3d025e7347f283bd0b295a356e7e67531f77156ed29c87d8e2688c9
MD5 6c17e7d5876b6254c8d45df511d10b38
BLAKE2b-256 cadef3986845a059df2089b780e3cabfe22e8bc69c44bfcbd27b973a5427fb1a

See more details on using hashes here.

File details

Details for the file operate_tools-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: operate_tools-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for operate_tools-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c5a87f2b3a303d5e5aa14d0fe724e6205c4ccab6ef87b69b462603d5c8b91b94
MD5 6a8ca0b53d2d0bdc864be2ff4a5ae52d
BLAKE2b-256 3515665e2b7441bdefcae5766cd5f026cc9c44a3759220d1e3832c3828c1ca0c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page