python help获取帮助

来源:互联网 发布:cool edit pro有mac版 编辑:程序博客网 时间:2024/05/16 12:44

http://woodpecker.org.cn/abyteofpython_cn/chinese/ch03s06.html   

1.

     如果你需要某个Python函数或语句的快速信息帮助,那么你可以使用内建的help功能。尤其在你使用带提示符的命令行的时候,它十分有用。比如,运行help(str)——这会显示str类的帮助。str类用于保存你的程序使用的各种文本(字符串)。类将在后面面向对象编程的章节详细解释。

    按q退出帮助。
     类似地,你可以获取Python中几乎所有东西的信息。使用help()去学习更多关于help本身的东西!

 help('print')
      你应该注意到我特意在“print”上使用了引号,那样Python就可以理解我是希望获取关于“print”的帮助而不是想要它打印东西

http://askubuntu.com/questions/230994/python-2-7-no-documentation-found-when-typing-helpprint

2.

Question:

I have just installed Python 2.7 and Python 3.2 on my Ubuntu 12.04 (32 bit).

However if I open a Python 2.7 shell (python from a terminal) when I type help('print') I get the following message:
no documentation found for 'print'


How can I get to use the documentation in Python 2.7 as well?

Answer:

This looks like a bug of Python 2 as something like help("dir") works properly. It probably does not work because print is a special keyword, unlike Python 3. Stick to Python 3 or run the following command instead of help("print"):
help("__builtin__.print")
原创粉丝点击