import webbrowser
import asyncio
async def op(url):
await asyncio.sleep(0.01) #返回一个asyncio对象,sleep前面加asyncio= 真性睡眠
webbrowser.open(url)
if __name__ == "__main__":
loop = asyncio.get_event_loop()#创建协程池
url_list = ['http://www.4399.com/','http://www.4399.com/','http://www.4399.com/','http://www.4399.com/',]
tasks = []
for url in url_list:
c = op(url)
tasks.append(c)
loop.run_until_complete(asyncio.wait(tasks))#执行
loop.close()
[python] The coroutine opens multiple websites at the same time
Guess you like
Origin blog.csdn.net/Sgmple/article/details/112192919
Recommended
Ranking