Cris Rain
2021-03-25 21:42
采纳率: 100%
浏览 65

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 打赏 评论
  • 有问必答小助手 2021-03-26 15:11

    您好,我是问答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~

    如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

    ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632

    打赏 评论

相关推荐 更多相似问题