该文被密码保护。 阅读全文
摘要:
unittest参数化 1 import parameterized 2 import unittest,BeautifulReport 3 4 #数据驱动 5 #代码驱动 6 #关键字驱动 7 8 data = [ 9 ['admin','123456',True,'正常登录'], 10 ['ad 阅读全文
摘要:
单元测试unittest 1、单元测试用例 1 import unittest 2 def add(a,b): 3 return a + b 4 result = add(1,1) 5 6 class AddTest(unittest.TestCase): #继承unittest.TestCase 阅读全文
摘要:
一、多进程 1、多线程,多进程 多线程: 适用于io密集型任务 多进程 适用于cpu密集型任务 1 import multiprocessing,time,virtualenv 2 def down_load(): 3 time.sleep(5) 4 print('运行完了') 5 6 if __n 阅读全文
摘要:
一、锁 1、多个线程操作同一个数据的时候,就的加锁 实例: import threading num = 0 lock = threading.Lock() #申请一把锁 def add(): global num #lock.acquire() #加锁 #num+=1 #lock.release( 阅读全文
摘要:
一、守护线程 1、主线程结束,子线程立马结束 实例: 1 import threading,time 2 def down_load(): 3 time.sleep(5) 4 print('运行完了') 5 for i in range(10): 6 t = threading.Thread(tar 阅读全文
摘要:
一、线程池 实例: 1 import threadpool 2 import requests,time,threading 3 from hashlib import md5 4 def down_load_pic(url): 5 req = requests.get(url) 6 m = md5 阅读全文
摘要:
一、异步任务 实例: 1 import yagmail,threading 2 def send_mail(): 3 smtp = yagmail.SMTP(host='smtp.163.com',user='xmb@163.com', 4 password='fsdfsf') 5 smtp.sen 阅读全文
摘要:
一、多线程下载文件 1 import requests,time,threading 2 from hashlib import md5 3 result = {} 4 def down_load_pic(url): 5 req = requests.get(url) 6 m = md5(url.e 阅读全文