help()
은 전체적으로 __doc__
속성 (및 함수 인수의 인트로 스펙 션)을 기반으로하므로 모듈, 클래스 및 함수에 모두 docstring이 있는지 확인하십시오.
문서화 문자열이 하지 주석, 그것은 상단에 노출 된 문자열 리터럴 권리 :
>>> import requests
>>> requests.__doc__
'\nRequests HTTP library\n~~~~~~~~~~~~~~~~~~~~~\n\nRequests is an HTTP library, written in Python, for human beings. Basic GET\nusage:\n\n >>> import requests\n >>> r = requests.get(\'https://www.python.org\')\n >>> r.status_code\n 200\n >>> \'Python is a programming language\' in r.content\n True\n\n... or POST:\n\n >>> payload = dict(key1=\'value1\', key2=\'value2\')\n >>> r = requests.post(\'http://httpbin.org/post\', data=payload)\n >>> print(r.text)\n {\n ...\n "form": {\n "key2": "value2",\n "key1": "value1"\n },\n ...\n }\n\nThe other HTTP methods are supported - see `requests.api`. Full documentation\nis at <http://python-requests.org>.\n\n:copyright: (c) 2016 by Kenneth Reitz.\n:license: Apache 2.0, see LICENSE for more details.\n'
: 예를 들어
"""This is a module docstring, shown when you use help() on a module"""
class Foo:
"""Help for the class Foo"""
def bar(self):
"""Help for the bar method of Foo classes"""
def spam(f):
"""Help for the spam function"""
가 인기 타사 requests
모듈은 문서화 문자열이있다
은 help()
으로 직접 렌더링되고 모듈 내용 (재귀 적으로는 내용 docstrings)과 함께 표현됩니다.
>>> help('requests')
Help on package requests:
NAME
requests
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
[...]