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
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
呼叫
help
函數,可以看到一個函數或方法的字串文件。使用
dir
可以查看模組或物件都有那些方法。使用
ipython+?
查看使用pydoc查看字串文件
很多第三方庫, 都有他們自己的官網, 例如requests庫, jinja2庫等等. 所以如果你想用的庫,剛好有他們的官網, 可以上通過搜索他們的官網上去學習, 但是如果很不幸沒有, 那隻能透過別人的部落格或分享去學習, 如果等基礎到一定程度, 可以去直接看他們模組的源碼, 從中找到你需要的東西