有没有办法来安装python文档,使它可以像它是一个联机帮助? (我知道你可以下载文件的源文件,并在vim中阅读它们,使用更少或者其他方式,但是我正在考虑少量手动操作。不想自己滚动。)阅读终端中的Python文档?
0
A
回答
3
在Debian(和派生的发行版,如Ubuntu)上安装pydoc
包。然后你可以使用pydoc whatever
命令。
1
我不如果这是你想要的,但是你可以在IDLE中做的所有事情,你可以在命令行上执行。例如:
C:>python
>>help(print())
>>help(plt.plot())
这样你就可以访问文档
2
我不知道这是你正在寻找什么,但Python交互式控制台提供help
命令。您可以按照以下方式使用它。
>>> help()
Welcome to Python 3.6'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.6/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> list
这将输出所有list
方法的全部文档。
3
这不是文档的确切副本,但有内置的help()
function。
在交互式的Python会话,你刚才叫help(whatever_you_want_to_read_about)
,例如:
>>> help(all)
Help on built-in function all in module builtins:
all(...)
all(iterable) -> bool
Return True if bool(x) is True for all values x in the iterable.
If the iterable is empty, return True.
或者,您也可以启动一个交互式帮助会话是这样的:
C:\Users\Rawing>python -c "help()"
Welcome to Python 3.4! This is the interactive help utility.
help>
然后就是键入你想知道的功能/类/模块:
help> all
Help on built-in function all in module builtins:
all(...)
all(iterable) -> bool
Return True if bool(x) is True for all values x in the iterable.
If the iterable is empty, return True.
1
您可以使用help(Class-name/method-name/anything)
。而且采用__doc__
特殊__doc__
文档字符串连接到每一个类和方法。例如,看看我输入我的翻译。
>>> print(str.__doc__)
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'.
>>> print(int.__doc__)
int(x=0) -> integer
int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments
are given. If x is a number, return x.__int__(). For floating point
numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string,
bytes, or bytearray instance representing an integer literal in the
given base. The literal can be preceded by '+' or '-' and be surrounded
by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
Base 0 means to interpret the base from the string as an integer literal.
>>> int('0b100', base=0)
4
它甚至适用于模块。
>>> import math
>>> math.__doc__
'This module is always available. It provides access to the\nmathematical functions defined by the C standard.'
>>> math.ceil.__doc__
'ceil(x)\n\nReturn the ceiling of x as an Integral.\nThis is the smallest integer >= x.'
>>>
因为每个类都有一个__doc__
这是附加给它的文档字符串你可以使用CLASS_NAME .__ doc__会给出
>>> print(ord.__doc__)
Return the Unicode code point for a one-character string.
相关问题
- 1. 如何阅读Emacs中的python文档
- 2. 从Python中读取终端
- 3. 阅读python中的文件
- 4. 阅读UWP中的MS WORD文档
- 5. 阅读c#中的复合文档#
- 6. 阅读C#中的word文档
- 7. 阅读java中的微软word文档
- 8. XCode文档 - 脱机阅读
- 9. 如何阅读Javascript文档?
- 10. JavaScript - 阅读XML文档
- 11. PHP,文档阅读库
- 12. Mac终端文档搜索
- 13. Python阅读文件
- 14. Python文件阅读
- 15. python阅读文件
- 16. 阅读python文件
- 17. 问题与阅读文字粘贴在终端
- 18. 阅读终端/外壳中光标位置的内容
- 19. 使用终端man命令阅读手册页中的章节
- 20. 如何阅读终端控制台中的最后一行?
- 21. 如何阅读node.js中的终端输入?
- 22. 阅读JSON文档并在Rails中创建一个新文档
- 23. 阅读文本文档存储过程
- 24. 阅读的文档使用C#
- 25. Word文档的阅读索引(目录)
- 26. 阅读一个大的Excel文档
- 27. 阅读Word文档的Java库
- 28. 阅读python中的* .lz4文件
- 29. 阅读Python中的打印文件
- 30. 阅读python中的txt文件2.5
如果你在一个交互式shell中运行蟒蛇调用它,你可以使用'help()'获得(部分)文档。 –