0
点赞
收藏
分享

微信扫一扫

自学Python:学习使用python帮助功能

我们不太可能记住所有函数的使用方法,在关键的时候要学会调用函数的帮助说明来看。

help() 函数用来查看某个函数或者模块的帮助文档,它的用法为:

help(input)

执行结果:

input(prompt=None, /)

    Read a string from standard input.  The trailing newline is stripped.


   The prompt string, if given, is printed to standard output without a

    trailing newline before reading input.


    If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.

    On *nix systems, readline is used if available.

input表示要查看的对象。input可以不写,此时 help() 会进入帮助子程序。

还有一个就是dir() 

dir() 函数用来列出某个类或者某个模块中的全部内容,包括变量、方法、函数和类等,它的用法为:

dir(input)

input表示要查看的对象。input可以不写,此时 dir() 会列出当前范围内的变量、方法和定义的类型。

掌握了以上两个函数,我们就可以自行查阅 Python 中所有方法、函数、变量、类的用法和功能了。

________________END______________

举报

相关推荐

0 条评论