怎样在spyder中查看函数源码[wingide使用教程]
我们经常会需要在Spyder中查看Python中某个函数的源码,比如在这里我想查看requests模块中get函数的源码,我可以输入以下两行代码实现:
import inspect as istprint(ist.getsource(requests.get))
也就是:
import requestsimport inspect as ist
print(ist.getsource(requests.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 or bytes to be sent 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)
相关文章教程推荐:spyder教程
以上是 怎样在spyder中查看函数源码[wingide使用教程] 的全部内容, 来源链接: utcz.com/z/526832.html