尝试连接到本地主机时的 InvalidSchema [重复]
Posted
技术标签:
【中文标题】尝试连接到本地主机时的 InvalidSchema [重复]【英文标题】:InvalidSchema when trying to connect to localhost [duplicate] 【发布时间】:2014-04-24 05:20:19 【问题描述】:我正在尝试使用 python 消息库执行发布请求。我有
>>> import requests
>>> p =
'email':'*****',
'passwd':'*****',
>>> r = requests.post('127.0.0.1:8000/mysite/',data=p)
这是回溯:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "c:\envs\r1\lib\site-packages\requests\api.py", line 88, in post
return request('post', url, data=data, **kwargs)
File "c:\envs\r1\lib\site-packages\requests\api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "c:\envs\r1\lib\site-packages\requests\sessions.py", line 383, in request
resp = self.send(prep, **send_kwargs)
File "c:\envs\r1\lib\site-packages\requests\sessions.py", line 481, in send
adapter = self.get_adapter(url=request.url)
File "c:\envs\r1\lib\site-packages\requests\sessions.py", line 526, in get_adapter
raise InvalidSchema("No connection adapters were found for '%s'" % url)
InvalidSchema: No connection adapters were found for '127.0.0.1:8000/mysite/'
我该如何解决这个问题?
【问题讨论】:
【参考方案1】:您的网址缺少方案;使用http://127.0.0.1:8000/mysite/
:
r = requests.post('http://127.0.0.1:8000/mysite/', data=p)
【讨论】:
以上是关于尝试连接到本地主机时的 InvalidSchema [重复]的主要内容,如果未能解决你的问题,请参考以下文章
Laravel 5 '..failed to open stream: Permission denied' 连接到本地主机时出现异常 [重复]