2.1.3 查询帮助文件

Python语言及其数据科学生态系统是根据用户需求而创建的,在编程过程中可以轻松获取帮助文件。

(1)使用help()函数获取print函数的帮助文件

命令:help(print)

输出结果:

Help on built-in function print in module builtins:print(...)

print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)

Prints the values to a stream, or to sys.stdout by default.

Optional keyword arguments:

file: a file-like object (stream); defaults to the current sys.stdout.

sep: string inserted between values, default a space.

end: string appended after the last value, default a newline.

flush: whether to forcibly flush the stream.

(2)使用问号“?”获取print函数的帮助文件

命令:print?

输出结果:

Docstring:

print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)

Prints the values to a stream, or to sys.stdout by default.

Optional keyword arguments:

file: a file-like object (stream); defaults to the current sys.stdout.

sep: string inserted between values, default a space.

end: string appended after the last value, default a newline.

flush: whether to forcibly flush the stream.

Type: builtin_function_or_method