代码改变世界

[python]help 函数

2015-11-23 10:44  sophia194910  阅读(227)  评论(0编辑  收藏  举报

1.在python中,如果对某个函数不了解,可以使用help(‘函数名’)来帮助获得函数的相关信息

示例:

help(raw_input)

运行结果:

Help on function raw_input in module sitecustomize:

raw_input(prompt='')
    raw_input([prompt]) -> string
    
    Read a string from standard input.  The trailing newline is stripped.
    If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.
    On Unix, GNU readline is used if enabled.  The prompt string, if given,
    is printed without a trailing newline before reading.

从打印的结果可以看出,raw_input用于从标准输入读取一个字符串。遇到EOF后,开始执行。在Windows下,输入字符串后,按下Enter键即可。