此库从新封装了python下常用的数据类型,在内置模块的基础扩展了部分功能.
Project description
这个库是python内置库的一个扩展库.把python的datetime,string,list,dist等数据结构重新进行了封装,扩展了部分功能.
- 适用对象:python工程师
- 作者:熊利宏
- 邮箱:xionglihong@163.com 有任何意见欢迎发送邮件,我们一起打造一个好用的python内置库的扩展库
什么是xToolkit库?
库xToolkit的中文名字叫X工具集.是python内置库的一个扩展库.把python的datetime,string,list,dist等数据结构重新进行了封装,扩展了部分功能.
操作文档
https://www.showdoc.cc/xToolkit?page_id=2133295307421808
更新说明:
2019年05年10日 V0.0.10 上线并新增获取当前时间功能
2019年05年16日 V0.0.12 新增格式化时间format功能,更人性化的输出时间格式
2019年05月18日 V0.0.15 新增推移时间功能
2019年05月19日 V0.0.16 新增替换时间功能
2019年05月25日 V0.0.17 新增判断时间格式是否正确功能
2019年05月26日 V0.0.17 新增获取时间区间功能
2019年05月27日 V0.0.17 新增获取时间区间内,星期字典功能
2019年05月31日 V0.0.19 新增多线程模块,简化了线程创建,销毁等操作
2019年06月11日 V0.0.21 新增计算人员岁数功能
实例:
导入xToolkit库
from xToolkit import xdatetime
判断时间格式时分正确
#判断时间格式"1988-07-20"是否合规
xdatetime.shape("1988-07-20")
>>True
#判断时间格式"1988-07-88"是否合规
xdatetime.shape("1988-07-88")
>>False
#判断时间格式"98787987"是否合规
xdatetime.shape("98787987")
>>False
获取时间起止
#获取当月第一天和最后一天
xdatetime.start_and_end()
>>['2019-05-01', '2019-05-31']
#获取下个月第一天和最后一天
xdatetime.start_and_end(space=1)
>>['2019-06-01', '2019-06-30']
#获取上个月月第一天和最后一天
xdatetime.start_and_end(space=-1)
>>['2019-04-01', '2019-04-30']
#获取今年第一天和最后一天
xdatetime.start_and_end(genre="Y"))
>>['2019-01-01', '2019-12-31']
#获取明年第一天和最后一天
xdatetime.start_and_end(genre="Y", space=1)
>>['2020-01-01', '2020-12-31']
#获取去年第一天和最后一天
xdatetime.start_and_end(genre="Y", space=-1)
>>['2018-01-01', '2018-12-31']
获取日期星期列表字典
#获取"2019-05-01"到"2019-05-08"的星期列表字典
xdatetime.get_week_dict(start="2019-05-01", end="2019-05-08")
>>{'1': ['2019-05-06'], '2': ['2019-05-07'], '3': ['2019-05-01', '2019-05-08'], '4': ['2019-05-02'], '5': ['2019-05-03'], '6': ['2019-05-04'], '7': ['2019-05-05']}
多线程带参数的案例:
#定义三个函数,用于测试
#每个函数各自停顿一段时间,表示运算耗时
def fib(arguments):
sleep(2)
return "0"
def fac(arguments):
sleep(3)
return "1"
def sum(arguments):
sleep(3)
return "2"
funcs = [fib, fac, sum]
# 参数样式
arguments = {"fib": [1], "fac": [2], "sum": [3]}
res = xthreading.xthreading(funcs,arguments)
#res的返回值为[{'fib': '0'}, {'fac': '1'}, {'sum': '2'}]
#从上面的三个函数看,里面分别停顿2,3,3秒,如果是单线程执行,耗时为8秒,用xthreading多线程实现功能仅耗时3秒
更多实例请参照参考文档
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xToolkit-0.0.21.tar.gz
(5.5 kB
view hashes)