1.邮箱验证: re.compile(r"^[a-z0-9.-\_]{1,50}@[a-z0-9-]+(.[a-z]{2,5}){1,2}$", re.I).match(datas["email"])
2.传url链接: parse.urlencode(字典) parse.unquote(字符串)
3.在装饰函数: import functools @functools.wraps(view_func)--->确保内部变量都是自身的内部变量
improt time
def timer(func):
def deco(*args, **kwargs):
start = time.time()
func(*args, **kwargs)
stop = time.time()
print(stop-start)
return deco
@timer
def test(parameter): #8
time.sleep(2)
print("test is running!")
test()
4.时间的算法:import datetime datetime.datetime.now() - datetime.timedelta(seconds=15) >st: