python多線程測試接口性能
import requests import json import threading import time # 定義請求基本地址 base_url = "http://127.0.0.1:8000" success = 0 fail = 0 # 查詢線程 def get_guest_list_thread(start_user,end_user): for i in range(start_user,end_user): phone = 13511001095 + i #13511001100 r = requests.get(base_url+‘/api/get_guest_list/‘, params={‘eid‘:1,‘phone‘:phone}) # print(r.status_code) # 200 # print(r.content) # b‘{"status": 200, "message": "success", "data": {"realname": "alen", "phone": "13511001100", "email": "[email protected]