如果您使用的是带有python(3.8 或更高版本)和aiohttp(3.7.4 或更低版本)的Windows 操作系统, 有时像这样的异常的解决方案是:
... Cannot connect to host <REQUESTED URL>:443 ssl:default [The parameter is incorrect]
import sys
...
policy = asyncio.WindowsSelectorEventLoopPolicy()
asyncio.set_event_loop_policy(policy)
asyncio.run(main())
您可以检查您的 Python 版本和操作系统:
import sys
...
if (sys.platform.startswith('win')
and sys.version_info[0] == 3
and sys.version_info[1] >= 8):
policy = asyncio.WindowsSelectorEventLoopPolicy()
asyncio.set_event_loop_policy(policy)
asyncio.run(main())