报错requests.exceptions.InvalidSchema: No connection adapters were found for
Posted gaoyubo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了报错requests.exceptions.InvalidSchema: No connection adapters were found for相关的知识,希望对你有一定的参考价值。
刚开始学习,使用requests时,敲了点demo
1 import requests 2 3 params = { 4 "name": "name", 5 "password": "高宇博" 6 } 7 8 res = requests.get("127.0.0.1:8000", params=params)
结果出现错误
C:UsersgaoyuEnvspy_path1Scriptspython.exe D:/python3.6/spider/demo/requests_test.py Traceback (most recent call last): File "D:/python3.6/spider/demo/requests_test.py", line 8, in <module> res = requests.get("127.0.0.1:8000", params=params) File "C:UsersgaoyuEnvspy_path1libsite-packages equestsapi.py", line 75, in get return request(‘get‘, url, params=params, **kwargs) File "C:UsersgaoyuEnvspy_path1libsite-packages equestsapi.py", line 60, in request return session.request(method=method, url=url, **kwargs) File "C:UsersgaoyuEnvspy_path1libsite-packages equestssessions.py", line 533, in request resp = self.send(prep, **send_kwargs) File "C:UsersgaoyuEnvspy_path1libsite-packages equestssessions.py", line 640, in send adapter = self.get_adapter(url=request.url) File "C:UsersgaoyuEnvspy_path1libsite-packages equestssessions.py", line 731, in get_adapter raise InvalidSchema("No connection adapters were found for ‘%s‘" % url) requests.exceptions.InvalidSchema: No connection adapters were found for ‘127.0.0.1:8000‘
最后发现原因很简单,就是因为url前面需要加http://
以上是关于报错requests.exceptions.InvalidSchema: No connection adapters were found for的主要内容,如果未能解决你的问题,请参考以下文章