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

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

报告相同问题?