Có cách nào để tìm kiếm một gói/chức năng cụ thể bằng các từ khóa trong bảng điều khiển Python không?Cách tìm kiếm trợ giúp bằng bàn điều khiển python
Ví dụ: tôi có thể tìm kiếm "pdf" cho các tác vụ liên quan đến pdf.
Có cách nào để tìm kiếm một gói/chức năng cụ thể bằng các từ khóa trong bảng điều khiển Python không?Cách tìm kiếm trợ giúp bằng bàn điều khiển python
Ví dụ: tôi có thể tìm kiếm "pdf" cho các tác vụ liên quan đến pdf.
Cờ pydoc -k
tìm kiếm tài liệu.
pydoc -k <keyword>
Search for a keyword in the synopsis lines of all available modules.
Từ một thiết bị đầu cuối, chạy ..
$ pydoc -k pdf
..ví dụ:
$ pydoc -k pdf
PdfImagePlugin
wx.lib.pdfwin
PIL.PdfImagePlugin
Nó không tìm kiếm các nội dung của các tài liệu, nhưng nó tìm kiếm tất cả các tên mô-đun - nếu đó là không đủ, tôi muốn đề nghị sử dụng Google hoặc StackOverflow để tìm kiếm "mô-đun PDF Python" hoặc tương tự
'pydoc' không được công nhận là lệnh nội bộ hoặc bên ngoài, chương trình có thể hoạt động hoặc tệp hàng loạt. (Win) –
Hãy thử help()
hoặc dir()
. AFAIR không có hỗ trợ dựng sẵn cho các tác vụ liên quan đến pdf trong cài đặt Python đơn giản. Một cách khác để tìm sự giúp đỡ cho các module Python là để google;)
Documents:
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')
>>> _
Bạn phải có dir python chính trong con đường của bạn. Và nó sẽ không hoạt động dưới IDLE. HTH.
@Umair - sử dụng hệ thống trợ giúp đi kèm với cài đặt python của bạn. Bạn cũng có thể thử điều này - http://pypi.python.org/pypi?:action=browse - đó là danh sách các mô-đun python, được sắp xếp theo chủ đề. @Jaime - bạn có thể sử dụng trợ giúp ('math') mà không cần nhập bất kỳ thứ gì. – uolot
Trong giao diện điều khiển loại giúp đỡ (object):
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
....
Unfortunatelly không có sự giúp đỡ cho pdf:
>>> help(pdf)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'pdf' is not defined
>>>
Như paffnucy nói thử tìm kiếm internet (SO việc wery tốt :)
Trang web này cũng hữu ích: http://www.gotapi.com/python
Bạn có thể sử dụng trợ giúp để truy cập docstrings các module khác nhau mà bạn đã nhập khẩu, ví dụ, hãy thử như sau:
help(math)
và bạn sẽ nhận được một lỗi,
import math
help(math)
và bạn sẽ nhận được một danh sách các phương pháp có sẵn trong mô-đun, nhưng chỉ SAU KHI bạn đã nhập nó. Nó cũng hoạt động với các chức năng riêng lẻ, ví dụ: sau khi nhập toán, hãy thử:
help(math.sin)
Để xử lý pdf, bạn có thể sẽ phải cài đặt mô-đun bên thứ ba. Một tìm kiếm nhanh chóng đã dẫn tôi đến kết quả này, mà tôi đã không cố gắng:
http://www.devshed.com/c/a/Python/Python-for-PDF-Generation/
giúp đỡ ("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".
>>>
(Nhiều năm sau) bây giờ tôi sử dụng pip search
và yolk -M hoặc tên gói -H: -M cho siêu dữ liệu, -H để duyệt đến trang web của mình.
Để tìm kiếm thông tin gói PyPI (Chỉ mục gói Python) tại địa phương, hãy thử pypi-grep
. Một ví dụ: 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
chỉ là một tập tin với một dòng dài mỗi gói PyPI, với các thông tin mà bạn nhìn thấy ở trên, cộng với một kịch bản bash tầm thường để egrep tập tin.
Tại sao? Tham khảo một tệp cục bộ rất nhanh và rất đơn giản, đối với các tên miền cũ và các tìm kiếm đơn giản: "XYZ là gì?"
hg clone http://bitbucket.org/denisb/pypi-grep/
nên tải xuống pypi-grep
và pypi-grepfile-2009-06-08
hoặc tương tự; chuyển chúng vào thư mục trong PATH của bạn. (. Đầu tiên easy_install hg
nếu bạn không có hg
)
Ghi chú:
các pypi-grepfile chỉ có một phiên bản cho mỗi gói, mới nhất; tóm tắt nhiều dòng được xếp thành một dòng dài (mà tôi đã cắt với pypi-grep | less -iS
).
pypi-grep -h
danh sách một vài lựa chọn
Các dữ liệu đến từ http://pypi.python.org/pypi XmlRpc, nhưng hãy cẩn thận: một số gói trong list_packages không có package_releases hoặc không releasedata, và một vài releasedatas timeout (timeout_xmlrpclib); những gì bạn thấy là Tất cả những gì bạn nhận được.
Phản hồi được hoan nghênh.
Xin lỗi tôi đã không đề cập đến việc tôi đang sử dụng các cửa sổ ... Tôi sẽ cố gắng tìm giải pháp tương tự cho các cửa sổ. –
Bạn có thể tìm kiếm các mô-đun có chứa "pdf" trong mô tả của chúng bằng cách chạy lệnh help("modules pdf")
.
Suy nghĩ một cách đệ quy:
>>> 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).
|
...
từ đây:
>>> import pydoc
>>> help(pydoc)
Help on module pydoc: ....
rất nhiều thông tin cần thiết về tìm kiếm trong tài liệu python đó.
pip là một tài nguyên tuyệt vời. Nếu pip được cài đặt (nếu bạn không có nó, hướng dẫn là here), sau đó sử dụng lệnh shell Windows bạn có thể làm như sau:
pip search pdf
Nó trả về một loạt các tùy chọn.
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
, vv
tôi cần để có thể "tìm kiếm" các gói ... pdf được chỉ được sử dụng như một ví dụ ở đây ... sử dụng "giúp đỡ" hoặc "dir" chức năng chỉ giúp nếu tôi biết những gì gói để sử dụng ở nơi đầu tiên. –
Tôi cần một cái gì đó như "tài liệu mô-đun" được cung cấp với các cửa sổ phân phối .. tuy nhiên tôi cần phải làm điều đó mặc dù giao diện điều khiển. –