Cris Rain 2021-03-25 21:42 采纳率: 80%
浏览 270
已采纳

python3.8request got an unexpected... Timeout

import requests
url = 'https://book.douban.com/subject/25862578/comments/'
headers = {'User- Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3861.400 QQBrowser/10.7.4313.400'}
r = requests.get(url, headers = headers, Timeout=(3.05, 27))

运行之后出现报错

TypeError: request() got an unexpected keyword argument 'Timeout'

requests版本

pip show requests
Name: requests
Version: 2.25.1
Summary: Python HTTP for Humans.
Home-page: https://requests.readthedocs.io
Author: Kenneth Reitz
Author-email: me@kennethreitz.org
License: Apache 2.0
Location: e:\anaconda\lib\site-packages
Requires: chardet, urllib3, idna, certifi
Required-by: Sphinx, jupyterlab-server, conda, conda-build, anaconda-project, anaconda-client
Note: you may need to restart the kernel to use updated packages.
  • 写回答

2条回答 默认 最新

  • CSDN专家-HGJ 2021-03-25 21:44
    关注

    应该是timeout,不是Timeout,所以报无此参数错误。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊