python - 为什么它显示错误,即 __init()__ 需要 1 个位置参数,但是当我在请求模块的 get 方法中传递 url 时给出了 2 个
问题描述
我正在尝试使用请求模块的 get 方法,但它不起作用。有人可以帮我解决这个问题吗?
import requests
r = requests.get('https://www.python.org')
print(r.status_code)
这是我的错误:
$ python request_testing.py
Traceback (most recent call last):
File "request_testing.py", line 4, in <module>
get('http://www.python.org')
File "C:\Python38\lib\site-packages\requests\adapters.py", line 412, in send
conn = self.get_connection(request.url, proxies)
File "C:\Python38\lib\site-packages\requests\adapters.py", line 315, in get_connection
conn = self.poolmanager.connection_from_url(url)
File "C:\Python38\lib\site-packages\urllib3\poolmanager.py", line 298, in connection_from_url
return self.connection_from_host(
File "C:\Python38\lib\site-packages\urllib3\poolmanager.py", line 245, in connection_from_host
return self.connection_from_context(request_context)
File "C:\Python38\lib\site-packages\urllib3\poolmanager.py", line 260, in connection_from_context
return self.connection_from_pool_key(pool_key, request_context=request_context)
File "C:\Python38\lib\site-packages\urllib3\poolmanager.py", line 281, in connection_from_pool_key
pool = self._new_pool(scheme, host, port, request_context=request_context)
File "C:\Python38\lib\site-packages\urllib3\poolmanager.py", line 213, in _new_pool
return pool_cls(host, port, **request_context)
File "C:\Python38\lib\site-packages\urllib3\connectionpool.py", line 197, in __init__
self.pool = self.QueueCls(maxsize)
TypeError: __init__() takes 1 positional argument but 2 were given
解决方案
推荐阅读
- xcode - Flutter - 为 iOS 构建,但链接和嵌入式框架“App.framework”是为 iOS 模拟器构建的
- laravel - 您如何在 Carbon Laravel 中更改印度尼西亚的日期格式?
- sql - 显示异常前的输出
- node.js - 如何将依赖项注入 Firebase/Google Cloud Functions?(单元和集成测试)
- authentication - 使用 PGP 密钥对登录
- java - 如何使用 Java 在 Android 的 reyclerview 中存储与每个项目相关的一些背景信息?
- bash - Windows 10 Git bash:cat:/etc/version:没有这样的文件或目录
- c++ - 没有规则可以在 Eclipse 中将目标全部放在 cpp 中
- kubernetes - 如何获取 Kubernetes 中的自定义属性?
- php - Laravel:更新时的验证 alpha 和正则表达式模式