>  기사  >  백엔드 개발  >  Python에 내장된 도움말 기능에 대한 자세한 소개

Python에 내장된 도움말 기능에 대한 자세한 소개

高洛峰
高洛峰원래의
2017-03-21 10:49:192291검색

영어 문서:

help([object])

내장 도움말 시스템을 호출합니다. (이 함수는 대화형 사용을 위한 것입니다.) 인수가 지정되지 않은 경우 인수가 다음과 같은 경우 대화형 도움말 시스템이 시작됩니다. 문자열인 경우 문자열은 모듈, 함수, 클래스, 메소드, 키워드 또는 문서 항목의 이름으로 조회되고 인수가 다른 종류의 객체인 경우 도움말 페이지가 콘솔에 인쇄됩니다. 개체에 대한 페이지가 생성됩니다.

이 함수는 site 모듈에 의해 내장 네임스페이스에 추가됩니다.

설명:

1. 인터프리터 대화형 인터페이스에서 매개변수를 전달하지 않고 함수를 호출하면 내장 도움말 시스템이 활성화되고 도움말 시스템으로 들어갑니다. 도움말 시스템 내에 모듈, 클래스, 함수 등의 이름을 입력하면 해당 사용 지침이 표시됩니다. 내장 도움말 시스템을 종료하고 대화형 인터페이스로 돌아가려면 quit를 입력합니다.

>>> help() #不带参数

Welcome to Python 3.5's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/3.5/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics".  Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".

#进入内置帮助系统  >>> 变成了 help>
help> str #str的帮助信息
Help on class str in module builtins:

class str(object)
 |  str(object='') -> str
 |  str(bytes_or_buffer[, encoding[, errors]]) -> str
 |  
 |  Create a new string object from the given object. If encoding or
 |  errors is specified, then the object must expose a data buffer
 |  that will be decoded using the given encoding and error handler.
 |  Otherwise, returns the result of object.__str__() (if defined)
 |  or repr(object).
 |  encoding defaults to sys.getdefaultencoding().
 |  errors defaults to 'strict'.
 |  
 |  Methods defined here:
 |  
 |  __add__(self, value, /)
 |      Return self+value.
 ................................


help> 1 #不存在的模块名、类名、函数名
No Python documentation found for '1'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

help> quit #退出内置帮助系统

You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)".  Executing "help('string')"
has the same effect as typing a particular string at the help> prompt.

# 已退出内置帮助系统,返回交互界面 help> 变成 >>>
>>>

2. 인터프리터 대화형 인터페이스에서는 매개변수를 전달하여 함수를 호출할 때 매개변수가 모듈 이름, 클래스 이름, 함수 이름인지 확인합니다. 표시됩니다.

아아아아

위 내용은 Python에 내장된 도움말 기능에 대한 자세한 소개의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.