Traceback (most recent call last): File "D:\PyCharm的程序\pythonProject12.24\main.py", line 16, in <module> response = requests.get(image_url) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\程\AppData\Local\JetBrains\PyCharmCE2022.2\demo\PyCharmLearningProject\venv\Lib\site-packages\requests\api.py", line 73, in get return request("get", url, params=params, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\程\AppData\Local\JetBrains\PyCharmCE2022.2\demo\PyCharmLearningProject\venv\Lib\site-packages\requests\api.py", line 59, in request return session.request(method=method, url=url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\程\AppData\Local\JetBrains\PyCharmCE2022.2\demo\PyCharmLearningProject\venv\Lib\site-packages\requests\sessions.py", line 573, in request prep = self.prepare_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\程\AppData\Local\JetBrains\PyCharmCE2022.2\demo\PyCharmLearningProject\venv\Lib\site-packages\requests\sessions.py", line 484, in prepare_request p.prepare( File "C:\Users\程\AppData\Local\JetBrains\PyCharmCE2022.2\demo\PyCharmLearningProject\venv\Lib\site-packages\requests\models.py", line 368, in prepare self.prepare_url(url, params) File "C:\Users\程\AppData\Local\JetBrains\PyCharmCE2022.2\demo\PyCharmLearningProject\venv\Lib\site-packages\requests\models.py", line 439, in prepare_url raise MissingSchema( requests.exceptions.MissingSchema: Invalid URL '//i0.hdslb.com/bfs/general/f7b667011a46615732c701f4bb1d07f793f8d1df.png': No scheme supplied. Perhaps you meant http:////i0.hdslb.com/bfs/general/f7b667011a46615732c701f4bb1d07f793f8d1df.png?
时间: 2023-06-16 18:06:42 浏览: 277
Mac下anaconda中Spyder打开报错Traceback(most recent call last)…问题
5星 · 资源好评率100%
看起来你的代码使用了 Python 的 `requests` 库,在调用 `requests.get()` 函数时,抛出了一个 "MissingSchema" 异常。这意味着在你尝试请求的 URL 中缺少了一个有效的协议 (schema)。
你可以在你的 URL 前面加上一个有效的协议,例如 "https://" 或者 "http://"。例如,你可以将:
```
image_url = "//i0.hdslb.com/bfs/general/f7b667011a46615732c701f4bb1d07f793f8d1df.png"
response = requests.get(image_url)
```
替换为:
```
image_url = "https://i0.hdslb.com/bfs/general/f7b667011a46615732c701f4bb1d07f793f8d1df.png"
response = requests.get(image_url)
```
这应该能够解决你遇到的问题。
阅读全文