[英]Postman get status code 200 with no headers GET METHOD but python requests gets 500 error
[英]I don't understand where the get method of the requests object supported by the requests package for Python gets its code
我刚刚安装了请求 package。 它有效,这意味着我可以运行文档中的前两条指令而不会出错,即导入请求和 requests.get。
我不明白潜在的来源。 我在名为 requests 的站点包中看到一个目录。 它包含必要的__init__.py
,因此系统应接受它作为有效的 object 进行导入。 但是,我希望在目录中看到与脚本中的 get 相对应的get.py
但不存在这样的事情。 事实上,整个目录非常小。 一切都在哪里?
看看requests.__init__.py
但特别是第 123 行:
from .api import request, get, head, post, patch, put, delete, options
然后,如果您将 go 放入requests.api.py
中,您将找到get()
,这是该方法的源实现:
def get(url, params=None, **kwargs):
r"""Sends a GET request.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary, list of tuples or bytes to send
in the query string for the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects', True)
return request('get', url, params=params, **kwargs)
我很确定通过将get()
导入__init__.py
可以通过您最初导入的requests
模块使其可用/可调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.