码迷,mamicode.com
首页 > 其他好文 > 详细

报错requests.exceptions.InvalidSchema: No connection adapters were found for

时间:2020-01-01 13:39:17      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:rac   ack   python   ret   LIDS   name   开始学习   import   ssi   

刚开始学习,使用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:\Users\gaoyu\Envs\py_path1\Scripts\python.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:\Users\gaoyu\Envs\py_path1\lib\site-packages\requests\api.py", line 75, in get
    return request(get, url, params=params, **kwargs)
  File "C:\Users\gaoyu\Envs\py_path1\lib\site-packages\requests\api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\gaoyu\Envs\py_path1\lib\site-packages\requests\sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\gaoyu\Envs\py_path1\lib\site-packages\requests\sessions.py", line 640, in send
    adapter = self.get_adapter(url=request.url)
  File "C:\Users\gaoyu\Envs\py_path1\lib\site-packages\requests\sessions.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

标签:rac   ack   python   ret   LIDS   name   开始学习   import   ssi   

原文地址:https://www.cnblogs.com/gaoyubo/p/12128668.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!