2009-06-09 11 views
7

का उपयोग करके सहायता कैसे खोजें पाइथन कंसोल में कीवर्ड का उपयोग करके किसी विशेष पैकेज/फ़ंक्शन को खोजने का कोई तरीका है?पायथन कंसोल

उदाहरण के लिए, मैं पीडीएफ संबंधित कार्यों के लिए "पीडीएफ" खोजना चाहूंगा।

+0

मैं "खोज" के लिए संकुल में सक्षम होना चाहिए ... पीडीएफ सिर्फ एक उदाहरण यहाँ के रूप में प्रयोग किया जाता है ... "सहायता" या "dir" फ़ंक्शन का उपयोग केवल तभी मदद मैं पता करें कि पहले स्थान पर कौन सा पैकेज उपयोग करना है। –

+0

मुझे विंडोज वितरण के साथ प्रदान किए गए "मॉड्यूल डॉक्स" की तरह कुछ चाहिए .. हालांकि मुझे कंसोल के बावजूद इसे करने की ज़रूरत है। –

उत्तर

8

pydoc -k झंडा प्रलेखन खोज करता है।

pydoc -k <keyword> 
    Search for a keyword in the synopsis lines of all available modules. 

एक टर्मिनल, चलाने से ..

$ pydoc -k pdf 

..उदाहरण के लिए:

$ pydoc -k pdf 
PdfImagePlugin 
wx.lib.pdfwin 
PIL.PdfImagePlugin 

यह दस्तावेज़ीकरण की सामग्री को खोज नहीं करता है, लेकिन यह सब मॉड्यूल नाम खोज - अगर वह पर्याप्त नहीं है, मैं "अजगर पीडीएफ मॉड्यूल" या के लिए खोज करने के लिए गूगल या StackOverflow का उपयोग कर सुझाव देंगे समान

+2

'pydoc' को आंतरिक या बाहरी कमांड, ऑपरेट करने योग्य प्रोग्राम या बैच फ़ाइल के रूप में पहचाना नहीं गया है। (विन) –

0

help() या dir() आज़माएं। AFAIR सादे पायथन स्थापना में पीडीएफ से संबंधित कार्यों के लिए कोई अंतर्निहित समर्थन नहीं है। एक और तरीका है पायथन मॉड्यूल के लिए सहायता प्राप्त करने के लिए गूगल के लिए है;)

डॉक्स:

http://docs.python.org/library/functions.html#help

http://docs.python.org/library/functions.html#dir

संपादित करें:

>>> 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') 
>>> _ 

आप में मुख्य अजगर dir करना होगा आपका रास्ता। और यह आईडीएलई के तहत काम नहीं करेगा। HTH।

+0

@Umair - अपने पायथन स्थापना के साथ बंडल सहायता प्रणाली का उपयोग करें। आप यह भी कोशिश कर सकते हैं - http://pypi.python.org/pypi?:action=browse - यह विषय द्वारा क्रमबद्ध पायथन मॉड्यूल की एक सूची है। @ जैम - आप कुछ भी आयात किए बिना सहायता ('गणित') का उपयोग कर सकते हैं। – uolot

1

सांत्वना प्रकार सहायता (वस्तु) में:

>>> help(pdf) 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
NameError: name 'pdf' is not defined 
>>> 

paffnucy के रूप में कहा खोज इंटरनेट (अतः wery अच्छी तरह से काम करता है :)

कोशिश:

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 पीडीएफ के लिए कोई मदद नहीं है

यह साइट भी सहायक हो सकती है: http://www.gotapi.com/python

8

आप सहायता का उपयोग कर सकते हैं ,

import math 
help(math) 

help(math) 

और आपको एक त्रुटि प्राप्त होगा और आप उपलब्ध तरीकों की एक सूची मिलेगी: विभिन्न मॉड्यूल आप आयात किया है, जैसे की docstrings तक पहुँचने के लिए, निम्न प्रयास करें मॉड्यूल में, लेकिन केवल आपके द्वारा आयात किए जाने के बाद ही। यह व्यक्तिगत कार्यों के साथ भी काम करता है, उदा। गणित आयात करने के बाद प्रयास करें:

help(math.sin) 

पीडीएफ से निपटने के लिए आपको शायद एक तृतीय पक्ष मॉड्यूल स्थापित करना होगा। एक त्वरित खोज मुझे इस परिणाम है, जो मैं प्रयास नहीं किया है के लिए प्रेरित किया:

http://www.devshed.com/c/a/Python/Python-for-PDF-Generation/

5

मदद ("मॉड्यूल")

>>> 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". 

>>> 
2

(साल बाद) मैं अब का उपयोग pip search
और yolk -M या एच PackageName: मेटाडाटा के लिए -M, एच अपने वेब पेज के लिए ब्राउज़ करने के लिए।


PyPI (अजगर पैकेज सूचकांक) पैकेज की जानकारी खोज करने के लिए स्थानीय स्तर पर, pypi-grep प्रयास करें। एक उदाहरण: 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 सिर्फ PyPI पैकेज प्रति एक लंबी लाइन की जानकारी ऊपर दिखने के साथ , प्लस फ़ाइल egrep के लिए एक छोटी सी पार्टी स्क्रिप्ट के साथ एक फ़ाइल है।
क्यों? पुरानी यूनिक्स लोगों और सरल खोजों के लिए स्थानीय फ़ाइल को ग्रेपिंग करना बहुत तेज़ और बहुत आसान है: "XYZ क्या है?"

hg clone http://bitbucket.org/denisb/pypi-grep/ pypi-grep और pypi-grepfile-2009-06-08 या जैसा डाउनलोड करना चाहिए; उन्हें अपने पथ में एक निर्देशिका में ले जाएं। (। सबसे पहले easy_install hg अगर आप hg नहीं है)

नोट्स:

pypi-grepfile पैकेज में केवल एक संस्करण है, नवीनतम; मल्टीलाइन सारांश एक लंबी लाइन (जिसे मैं pypi-grep | less -iS के साथ काटता हूं) में जोड़ दिया जाता है।

pypi-grep -h सूचियों कुछ ही विकल्प

डेटा http://pypi.python.org/pypi xmlrpc, लेकिन सावधान रहना से आता है: list_packages में कुछ संकुल कोई package_releases या कोई releasedata है, और कुछ releasedatas समय-समाप्त (timeout_xmlrpclib); जो आप देखते हैं वह सब आपको मिलता है।

प्रतिक्रिया का स्वागत है।

+0

क्षमा करें मैं यह उल्लेख करने में असफल रहा कि मैं विंडोज़ का उपयोग कर रहा हूं ... मैं विंडोज़ के लिए समान समाधान खोजने की कोशिश करूंगा। –

4

आप help("modules pdf") आदेश चलाकर अपने विवरण में "पीडीएफ" युक्त मॉड्यूल की खोज कर सकते हैं।

1

रिकर्सिवली में सोच रही थी:

>>> 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). 
| 

... 

यहां से:

>>> import pydoc 
>>> help(pydoc) 
Help on module pydoc: .... 

वहाँ अजगर डॉक्स में खोज पर आवश्यक जानकारी के बहुत सारे।

3

पीआईपी एक उत्कृष्ट संसाधन है। पिप स्थापित किया गया है, तो विंडोज कमांड खोल का उपयोग कर आप निम्न कर सकते (यदि आप इसे ज़रूरत नहीं है, निर्देश here कर रहे हैं),:

pip search pdf 

यह विकल्पों में से एक बहुतायत देता है।

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 

आदि

संबंधित मुद्दे