# -*- coding: utf-8 -*- import requests import threading class GetRequests: def __init__(self): self.url = "http://www.baidu.com" def requestGetMethod(self): r = requests.get(self.url) print(r.text) print("==========================================================================") def threadBuild(): req = GetRequests() return req.requestGetMethod() try: i = 0 threadnums = 10 #线程数 while i < threadnums: re = threading.Thread(target=threadBuild) re.start() i += 1 except Exception as e: print(e)
python启多线程请求简单例子
最新推荐文章于 2024-06-06 11:13:11 发布