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

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条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵