Как мне увидеть документацию по Python для Linux? - PullRequest
27 голосов
/ 22 марта 2012

В Windows Python имеет документ типа chm, и его очень удобно читать. Но есть ли в Linux какой-нибудь документ, который мне стоит прочитать?

Ответы [ 7 ]

18 голосов
/ 13 октября 2014

Онлайн документация

Самый простой способ - использовать Google для доступа к онлайн-документации. Там нет единой точки, где вы найдете всю документацию всех модулей. Тем не менее, некоторые из них:

Если вам нужна автономная документация, есть несколько других возможностей:

Скачать

Вы можете скачать документацию в формате HTML или PDF: https://docs.python.org/3/download.html

Когда у вас работает веб-сервер, вы можете использовать HTML-версию и получать к ней доступ, как вы привыкли через браузер. HTML-сайт выглядит так же, как вы привыкли. Даже поиск работает в автономном режиме, потому что он реализован с помощью JavaScript.

enter image description here

PyDoc

В некоторых дистрибутивах, таких как Debian, предлагается пакет python-doc. Вы можете получить к нему доступ через pydoc -p [some port number] или через pydoc -g. Это создаст локальный веб-сервер. Затем вы можете открыть свой браузер и взглянуть на него:

enter image description here

Консоль: помощь (...)

Интерактивная консоль Python имеет встроенную систему help(...). Вы можете вызвать его без аргумента:

$ python
Python 2.7.5+ (default, Feb 27 2014, 19:37:08) 
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help()

Welcome to Python 2.7!  This is the online 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/2.7/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, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help> 

или вы можете позвонить с параметром, о котором хотите что-то узнать. Это может быть что угодно (модуль, класс, функция, объект, ...). Это выглядит так:

>>> a = {'b':'c'}
>>> help(a)
Help on dict object:

class dict(object)
 |  dict() -> new empty dictionary
 |  dict(mapping) -> new dictionary initialized from a mapping object's
 |      (key, value) pairs
 |  dict(iterable) -> new dictionary initialized as if via:
 |      d = {}
 |      for k, v in iterable:
 |          d[k] = v
 |  dict(**kwargs) -> new dictionary initialized with the name=value pairs
 |      in the keyword argument list.  For example:  dict(one=1, two=2)
 |  
 |  Methods defined here:
 |  
 |  __cmp__(...)
 |      x.__cmp__(y) <==> cmp(x,y)
 |  
 |  __contains__(...)
 |      D.__contains__(k) -> True if D has a key k, else False
 |  
 |  __delitem__(...)
 |      x.__delitem__(y) <==> del x[y]
 |  
 |  __eq__(...)
 |      x.__eq__(y) <==> x==y
 |  
 |  __ge__(...)
 |      x.__ge__(y) <==> x>=y
 |  
 |  __getattribute__(...)
 |      x.__getattribute__('name') <==> x.name
 |  
 |  __getitem__(...)
 |      x.__getitem__(y) <==> x[y]
 |  
 |  __gt__(...)
: (scroll)
9 голосов
/ 22 марта 2012

http://www.google.cz/search?q=linux+chm+viewer

Документы доступны в различных форматах: http://docs.python.org/download.html

Существует сервер документации Python, который вы можете запустить локально: http://docs.python.org/library/pydoc.html?highlight=pydoc#pydoc

6 голосов
/ 22 марта 2012

Если вы используете дистрибутив Fedora, то yum install python-docs.Другие дистрибутивы могут предоставлять аналогичные пакеты.

4 голосов
/ 22 марта 2012

Вы также можете установить Ipython для проверки модулей / объектов в интерактивном режиме.
Например, вы можете сделать это в ipython:

import pygame  
pygame.draw.line?

тогда вы получите результат doc:

pygame.draw.line (Surface, color, start_pos, end_pos, width = 1): вернуть Rect
нарисовать отрезок прямой линии

В ipython вы можете использовать табуляцию, это полезно для проверки чего-либо.

4 голосов
/ 22 марта 2012

Лучший способ - прочитать документацию, встроенную в оболочку Python.

$ python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> help()

Welcome to Python 2.7!  This is the online 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/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, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help> 
2 голосов
/ 06 марта 2013

используйте следующую команду pydoc -g

0 голосов
/ 22 марта 2012

Поскольку вы находитесь в Интернете, воспользуйтесь он-лайн документацией по питону .

...