56 lines
1.1 KiB
Python
56 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding:utf-8 -*-
|
||
import time
|
||
import datetime
|
||
from functools import wraps
|
||
|
||
"""
|
||
-------------------------------------------------
|
||
File Name:
|
||
Description :
|
||
Author : xiaobei
|
||
CreateDate:
|
||
wechat:xiaobei_upup
|
||
-------------------------------------------------
|
||
"""
|
||
|
||
def timestamp():
|
||
"""时间戳"""
|
||
return time.time()
|
||
|
||
|
||
def dt_strftime(fmt="%Y%m"):
|
||
"""
|
||
datetime格式化时间
|
||
:param fmt "%Y%m%d %H%M%S
|
||
"""
|
||
return datetime.datetime.now().strftime(fmt)
|
||
|
||
|
||
def sleep(seconds=1.0):
|
||
"""
|
||
睡眠时间
|
||
"""
|
||
time.sleep(seconds)
|
||
|
||
|
||
def running_time(func):
|
||
"""函数运行时间"""
|
||
|
||
@wraps(func)
|
||
def wrapper(*args, **kwargs):
|
||
start = timestamp()
|
||
res = func(*args, **kwargs)
|
||
print("校验元素done!用时%.3f秒!" % (timestamp() - start))
|
||
return res
|
||
|
||
return wrapper
|
||
|
||
|
||
if __name__ == '__main__':
|
||
@running_time
|
||
def aaaaa():
|
||
"""这里是aaaaa的docstring"""
|
||
print(dt_strftime("%Y%m%d%H%M%S"))
|
||
print(aaaaa.__doc__,aaaaa.__name__)
|
||
aaaaa() |