python报错RuntimeError: This event loop is already running

解决方法

首先安装:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple nest_asyncio

然后在代码中:

import nest_asyncio
nest_asyncio.apply()

原理

nest_asyncio作为异步操作的补丁而存在,具体内容请参考:https://www.blog.pythonlibrary.org/2016/07/26/python-3-an-intro-to-asyncio/

猜你喜欢

转载自blog.csdn.net/weixin_35757704/article/details/107949934