Gibt es eine Möglichkeit zur Suche nach einem bestimmten Paket/Funktion mit Schlüsselwörtern in der Python-Konsole?Suche nach Hilfe mit Python-Konsole
Zum Beispiel könnte ich "pdf" für pdf-bezogene Aufgaben suchen.
Gibt es eine Möglichkeit zur Suche nach einem bestimmten Paket/Funktion mit Schlüsselwörtern in der Python-Konsole?Suche nach Hilfe mit Python-Konsole
Zum Beispiel könnte ich "pdf" für pdf-bezogene Aufgaben suchen.
Die pydoc -k
Flagge sucht die Dokumentation.
pydoc -k <keyword>
Search for a keyword in the synopsis lines of all available modules.
Von einem Terminal laufen ..
$ pydoc -k pdf
..zum Beispiel:
$ pydoc -k pdf
PdfImagePlugin
wx.lib.pdfwin
PIL.PdfImagePlugin
Es sucht nicht den Inhalt der Dokumentation, aber es sucht alle Modulnamen - wenn das nicht genug ist, würde ich mit Google oder Stackoverflow vorschlagen „Python PDF-Modul“ suchen oder ähnlich
'pydoc' wird nicht als interner oder externer Befehl, ausführbares Programm oder Batch-Datei erkannt. (Win) –
Versuchen Sie help()
oder dir()
. AFAIR gibt es keine eingebaute Unterstützung für pdf-bezogene Aufgaben in der einfachen Python-Installation. Ein anderer Weg, um Hilfe für Python-Module zu finden, ist zu google;)
Docs:
http://docs.python.org/library/functions.html#help
http://docs.python.org/library/functions.html#dir
EDIT:
>>> import os
>>> def search_help(keyword):
... os.system('python Lib/pydoc.py -k %s' % keyword)
...
>>> search_help('math')
cmath - This module is always available. It provides access to mathematical
math - This module is always available. It provides access to the
test.test_cmath
test.test_math
>>> search_help('pdf')
>>> _
Du musst Haupt Python dir haben in dein Weg. Und es wird nicht unter IDLE funktionieren. HTH.
@Umair - Verwenden Sie das mit Ihrer Python-Installation gebündelte Hilfesystem. Sie können dies auch versuchen - http://pypi.python.org/pypi?:action=browse - es ist eine Liste von Python-Modulen, nach Themen sortiert. @Jaime - Sie können Hilfe ('Mathe') verwenden, ohne etwas zu importieren. – uolot
In Konsolentyp Hilfe (Objekt):
Python 2.6.2 (r262:71600, Apr 21 2009, 15:05:37) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> help(dir)
Help on built-in function dir in module __builtin__:
dir(...)
dir([object]) -> list of strings
....
Leider gibt es keine Hilfe für pdf:
>>> help(pdf)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'pdf' is not defined
>>>
Als paffnucy versuchen die Internet-Suche (SO funktioniert Wery gut :)
Diese Seite kann auch hilfreich sein: http://www.gotapi.com/python
Sie können Hilfe verwenden die Docstrings der verschiedenen Module zugreifen, die Sie importiert haben, zum Beispiel, versuchen Sie folgendes:
help(math)
und Sie werden einen Fehler,
import math
help(math)
und Sie erhalten eine Liste der verfügbaren Methoden erhalten erhalten im Modul, aber erst nachdem Sie es importiert haben. Es funktioniert auch mit individuellen Funktionen, z.B. Nach dem Importieren der Mathematik versuchen:
help(math.sin)
Um mit pdf umzugehen, müssen Sie wahrscheinlich ein Drittanbieter-Modul installieren. Eine schnelle Suche hat mich zu diesem Ergebnis geführt, die ich nicht versucht haben:
http://www.devshed.com/c/a/Python/Python-for-PDF-Generation/
Hilfe ("Module")
>>> help("modules")
Please wait a moment while I gather a list of all available modules...
C:\Program Files\Python26\lib\pkgutil.py:110: DeprecationWarning: The wxPython compatibility package is no longer automatically generated or actively maintained. Please switch to the wx package as soon
__import__(name)
ArgImagePlugin WmfImagePlugin dbhash pyclbr
BaseHTTPServer XVThumbImagePlugin decimal pydoc
Bastion XbmImagePlugin difflib pydoc_topics
BdfFontFile XpmImagePlugin dircache pyexpat
BmpImagePlugin _LWPCookieJar dis quopri
BufrStubImagePlugin _MozillaCookieJar distutils random
CGIHTTPServer __builtin__ doctest re
Canvas __future__ dumbdbm repr
ConfigParser _abcoll dummy_thread rexec
ContainerIO _ast dummy_threading rfc822
Cookie _bisect email rlcompleter
CurImagePlugin _bsddb encodings robotparser
DcxImagePlugin _bytesio errno runpy
Dialog _codecs exceptions sched
DocXMLRPCServer _codecs_cn filecmp select
EpsImagePlugin _codecs_hk fileinput sets
ExifTags _codecs_iso2022 fnmatch sgmllib
FileDialog _codecs_jp formatter sha
FitsStubImagePlugin _codecs_kr fpformat shelve
FixTk _codecs_tw fractions shlex
FliImagePlugin _collections ftplib shutil
FontFile _csv functools signal
FpxImagePlugin _ctypes future_builtins site
GbrImagePlugin _ctypes_test gc smtpd
GdImageFile _elementtree genericpath smtplib
GifImagePlugin _fileio getopt sndhdr
GimpGradientFile _functools getpass socket
GimpPaletteFile _hashlib gettext sqlite3
GribStubImagePlugin _heapq glob sre
HTMLParser _hotshot gzip sre_compile
Hdf5StubImagePlugin _imaging hashlib sre_constants
IcnsImagePlugin _imagingft heapq sre_parse
IcoImagePlugin _imagingmath hmac ssl
ImImagePlugin _imagingtk hotshot stat
Image _json htmlentitydefs statvfs
ImageChops _locale htmllib string
ImageColor _lsprof httplib stringold
ImageDraw _md5 idlelib stringprep
ImageDraw2 _msi ihooks strop
ImageEnhance _multibytecodec imageop struct
ImageFile _multiprocessing imaplib subprocess
ImageFileIO _random imghdr sunau
ImageFilter _sha imp sunaudio
ImageFont _sha256 imputil symbol
ImageGL _sha512 inspect symtable
ImageGrab _socket io sys
ImageMath _sqlite3 itertools tabnanny
ImageMode _sre json tarfile
ImageOps _ssl keyword telnetlib
ImagePalette _strptime lib2to3 tempfile
ImagePath _struct linecache test
ImageQt _subprocess locale textwrap
ImageSequence _symtable logging this
ImageStat _testcapi macpath thread
ImageTk _threading_local macurl2path threading
ImageTransform _tkinter mailbox time
ImageWin _warnings mailcap timeit
ImtImagePlugin _weakref markupbase tkColorChooser
IptcImagePlugin _winreg marshal tkCommonDialog
JpegImagePlugin abc math tkFileDialog
McIdasImagePlugin aifc md5 tkFont
MicImagePlugin anydbm mhlib tkMessageBox
MimeWriter array mimetools tkSimpleDialog
MpegImagePlugin ast mimetypes toaiff
MspImagePlugin asynchat mimify token
OleFileIO asyncore mmap tokenize
PIL atexit modulefinder trace
PSDraw audiodev msilib traceback
PaletteFile audioop msvcrt tty
PalmImagePlugin base64 multifile turtle
PcdImagePlugin bdb multiprocessing types
PcfFontFile binascii mutex unicodedata
PcxImagePlugin binhex netrc unittest
PdfImagePlugin bisect new update_manifest
PixarImagePlugin bsddb nntplib urllib
PngImagePlugin bz2 nt urllib2
PpmImagePlugin cPickle ntpath urlparse
PsdImagePlugin cProfile nturl2path user
Queue cStringIO numbers uu
ScrolledText calendar opcode uuid
SgiImagePlugin cgi operator warnings
SimpleDialog cgitb optparse wave
SimpleHTTPServer chunk os weakref
SimpleXMLRPCServer cmath os2emxpath webbrowser
SocketServer cmd parser whichdb
SpiderImagePlugin code pdb winsound
StringIO codecs pickle wsgiref
SunImagePlugin codeop pickletools wx
TarIO collections pipes wxPython
TgaImagePlugin colorsys pkgutil wxversion
TiffImagePlugin commands platform xdrlib
TiffTags compileall plistlib xml
Tix compiler popen2 xmllib
Tkconstants contextlib poplib xmlrpclib
Tkdnd cookielib posixfile xxsubtype
Tkinter copy posixpath zipfile
UserDict copy_reg pprint zipimport
UserList csv profile zlib
UserString ctypes pstats
WalImageFile curses pty
WbmpImagePlugin datetime py_compile
Enter any module name to get more help. Or, type "modules spam" to search
for modules whose descriptions contain the word "spam".
>>>
(Jahre später) ich verwende jetzt pip search
und yolk -M oder -H Paket: -M für Metadaten, um -H auf seine Web-Seite.
Um PyPI (Python Package Index) Paketinformationen lokal zu suchen, versuchen pypi-grep
. Ein Beispiel: pypi-grep 'pyqt'
->
# day status packagename version homepage summary
2009-06-07 3 "pydee" 0.4.11 http://code.google.com/p/pydee/
Pydee development environment and its PyQt4-based IDE tools: ...
2009-06-05 4 "Sandbox" 0.9.5 http://www.qtrac.eu/sandbox.html
A PyQt4-based alternative to IDLE
...
pypi-grep
ist nur eine Datei mit einer langen Zeile pro PyPI Paket, mit den Informationen, die Sie oben sehen, sowie ein trivialen Bash-Skript, um die Datei egrep.
Warum? Grepping eine lokale Datei ist sehr schnell und sehr einfach, für alte Unix Jungs und einfache Suche: "Was ist XYZ?"
hg clone http://bitbucket.org/denisb/pypi-grep/
sollten pypi-grep
und pypi-grepfile-2009-06-08
oder dergleichen herunterladen; verschieben Sie sie in ein Verzeichnis in Ihrem PATH. (. Zuerst easy_install hg
wenn Sie nicht hg
haben)
Hinweise:
das pypi-grepfile hat nur eine Version pro Paket, die neuesten; Multiline-Zusammenfassungen sind zu einer langen Linie (die ich mit pypi-grep | less -iS
hacken) gefaltet.
pypi-grep -h
listet einige Optionen
Die Daten stammen aus http://pypi.python.org/pypi xmlrpc, aber Vorsicht: einige Pakete in list_packages haben keine package_releases oder kein Release, und ein paar releasedatas Timeout (timeout_xmlrpclib); was Sie sehen, ist alles, was Sie bekommen.
Feedback ist willkommen.
Leider habe ich nicht erwähnt, dass ich Windows verwende ... Ich werde versuchen, eine ähnliche Lösung für Windows zu finden. –
Sie können in der Beschreibung nach Modulen suchen, die "pdf" enthalten, indem Sie den Befehl help("modules pdf")
ausführen.
Denken rekursiv:
>>> help(help)
Help on _Helper in module site object:
class _Helper(builtins.object)
| Define the builtin 'help'.
| This is a wrapper around **pydoc.help** (with a twist).
|
...
von hier:
>>> import pydoc
>>> help(pydoc)
Help on module pydoc: ....
viele wesentliche Informationen über Suche in Python gibt docs.
Pip ist eine ausgezeichnete Ressource. Wenn pip installiert ist (wenn Sie es nicht haben, Anweisungen sind here), dann die Windows-Befehlsshell verwenden, können Sie wie folgt vorgehen:
pip search pdf
Es hat eine Fülle von Optionen zurückgibt.
C:\Python27\Scripts>pip search pdf
mwlib.rl - generate pdfs from mediawiki markup
slc.publications - A content type to store and parse pdf publications
PyPDFLite - Simple PDF Writer.
pdfminer - PDF parser and analyzer
zopyx.convert - A Python interface to XSL-FO libraries (Conversion
HTML to PDF, RTF, DOCX, WML and ODT)
WeasyPrint - WeasyPrint converts web documents to PDF.
zopyx.convert2 - A Python interface for the conversion of HTML to
PDF, RTF, DOCX, WML and ODT) - belongs to
zopyx.smartprintng.core
collective.pdfpeek - A Plone 4 product that generates image thumbnail
previews of PDF files stored on ATFile based
objects.
pisa - PDF generator using HTML and CSS
usw.
Ich brauche die Pakete in der Lage sein zu „suchen“ ... pdf ist nur als Beispiel hier verwendet ... „help“ oder „dir“ Funktion nur Hilfe bei der Benutzung, wenn i wissen, welches Paket in erster Linie zu verwenden ist. –
Ich brauchte etwas wie "Modul-Dokumente", die mit der Windows-Distribution zur Verfügung gestellt werden .. aber ich muss es tun, obwohl die Konsole. –