导语:
本文主要介绍了关于python3如何看文档的相关知识,包括qpython,以及python文档这些编程知识,希望对大家有参考作用。
调用帮助函数以查看函数或方法的字符串文档。
In [1]: import requests
In [2]: help(requests.get)
Help on function get in module requests.api:
get(url, params=None, **kwargs)
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
使用dir可以查看模块或对象都有那些方法。
In [3]: dir(requests)
Out[3]:
['ConnectionError',
'HTTPError',
'compat',
'cookies',
'delete',
'exceptions',
'get',
'head',
'hooks',
...
使用ipython+?查看
In [4]: requests.get?
Type: function
String form: <function get at 0x10e6c35f0>
File: /Library/Python/2.7/site-packages/requests/api.py
Definition: requests.get(url, params=None, **kwargs)
Docstring:
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
使用pydoc查看字符串文档
~ python -m pydoc requests
Help on package requests:
NAME
requests
FILE
/Library/Python/2.7/site-packages/requests/__init__.py
DESCRIPTION
requests HTTP library
Requests is an HTTP library, written in Python, for human beings. Basic GET
usage:
>>> import requests
>>> r = requests.get('https://www.python.org')
>>> r.status_code
200
>>> 'Python is a programming language' in r.content
True
推荐学习《
》!
本文为原创文章,版权归知行编程网所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ python格式函数如何与字符串连接?11/15
- ♥ Python集合的特点是什么09/14
- ♥ 如何使用 Python OS 模块?01/07
- ♥ 如何在python中输入两行09/02
- ♥ python如何判断一个对象的属性10/28
- ♥ 在 Python 中合并两个列表、字典的多种方法10/11
内容反馈