xiaobei_selenium_automation/common/times.py

56 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import time
import datetime
from functools import wraps
"""
-------------------------------------------------
File Name
Description :
Author : xiaobei
CreateDate
wechatxiaobei_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()