D:\python3.9\python.exe C:/Users/Administrator/Desktop/pycharm代码/练习2.py
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\pycharm代码\练习2.py", line 5, in
page_text=requests.get(url=url,headers=headers).content
File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 677, in send
history = [resp for resp in gen]
File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 677, in
history = [resp for resp in gen]
File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 150, in resolve_redirects
url = self.get_redirect_target(resp)
File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 107, in get_redirect_target
location = resp.headers['location']
File "C:\Users\Administrator\AppData\Roaming\Python\Python39\site-packages\requests\structures.py", line 54, in getitem
return self._store[key.lower()][1]
KeyError: 'location'
请问报这种错误怎么解决
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- keenanli 2022-04-20 13:48关注
self._store你可以打印出来看看。
store没有location这个key本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录
悬赏问题
- ¥15 preLaunchTask"C/C++: aarch64- apple-darwin22-g++-14 生成活动 文件”已终止,退出代码为-1。
- ¥18 关于#贝叶斯概率#的问题:这篇文章中利用em算法求出了对数似然值作为概率表参数,然后进行概率表计算,这个概率表是怎样计算的呀
- ¥20 C#上传XML格式数据
- ¥15 elementui上传结合oss接口断点续传,现在只差停止上传和继续上传,各大精英看下
- ¥100 单片机hardfaulr
- ¥20 手机截图相片分辨率降低一半
- ¥50 求一段sql语句,遇到小难题了,可以50米解决
- ¥15 速求,对多种商品的购买力优化问题(用遗传算法、枚举法、粒子群算法、模拟退火算法等方法求解)
- ¥100 速求!商品购买力最优化问题(用遗传算法求解,给出python代码)
- ¥15 虚拟机检测,可以是封装好的DLL,可付费