jython查看帮助help和模块modules

jython运行环境是需要JAVA支持的,JAVA安装百度很多。

 

查看JAVA是否安装成功:

[root@node ~]# java -version
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

 

下载好jython包,进入到jython的jar包目录里:

[root@node2 win-share]# cd ~/jython/
[root@node2 win-share]# ls -l
-rwxrwxrwx. 1 root root  43056592 10月 31 20:51 jython-standalone-2.7.2.jar

 

jython有两种一种是包名上带“installer”字样的,代表是安装版;另一种是包名带“standalone”字样的,就可以直接用JAVA启动

这里以第二种standalone”字样举例

[root@node2 win-share]# cd ~/jython/
[root@node2 win-share]# java -jar jython-standalone-2.7.2.jar

  输入等待启动,启动后就和Python一样会出现“>>>”

进入帮助函数:

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

  看到help> ,已经就是进入帮助了。

 

查看jar包里有多少个模块:

help> modules

Please wait a moment while I gather a list of all available modules...

BaseHTTPServer      cmath               javapath            runpy
CGIHTTPServer       cmd                 javashell           sax
ConfigParser        code                jffi                sched
Cookie              codecs              json                select
DocXMLRPCServer     codeop              jythonlib           sets
HTMLParser          collections         keyword             sgmllib
MimeWriter          colorsys            lib2to3             sha
Queue               command             linecache           shelve
SimpleHTTPServer    commands            locale              shlex
SimpleXMLRPCServer  compileall          logging             shutil
SocketServer        compiler            macpath             signal
StringIO            contextlib          macurl2path         site
UserDict            cookielib           mailbox             smtpd
UserList            copy                mailcap             smtplib
UserString          copy_reg            markupbase          sndhdr
_LWPCookieJar       crypt               marshal             socket
_MozillaCookieJar   csv                 math                sre
__builtin__         ctypes              md5                 sre_compile
__future__          datetime            mhlib               sre_constants
_abcoll             dbexts              mime                sre_parse
_ast                decimal             mimetools           ssl
_bytecodetools      difflib             mimetypes           stat
_codecs             dircache            mimify              string
_collections        dis                 modjy               struct
_csv                distutils           multifile           subprocess
_fix_jython_setuptools_osx doctest             mutex               symbol
_fsum               dom                 netrc               synchronize
_functools          dumbdbm             new                 sys
_google_ipaddr_r234 dummy_thread        nntplib             sysconfig
_hashlib            dummy_threading     ntpath              tabnanny
_imp                email               nturl2path          tarfile
_io                 encodings           numbers             telnetlib
_json               ensurepip           opcode              tempfile
_jyio               errno               operator            test
_jythonlib          etree               optparse            tests
_locale             exceptions          os                  textwrap
_marshal            filecmp             parsers             this
_py_compile         fileinput           pawt                thread
_pyio               fixes               pdb                 threading
_random             fnmatch             pgen2               time
_rawffi             formatter           pickle              timeit
_socket             fpformat            pickletools         token
_sre                fractions           pipes               tokenize
_sslcerts           ftplib              pkgutil             trace
_strptime           functools           platform            traceback
_threading          future_builtins     plistlib            tty
_threading_local    gc                  popen2              types
_weakref            genericpath         poplib              ucnhash
_weakrefset         getopt              posix               unicodedata
abc                 getpass             posixfile           unittest
aifc                gettext             posixpath           urllib
anydbm              glob                pprint              urllib2
argparse            grp                 profile             urlparse
array               gzip                pstats              user
ast                 hashlib             pty                 uu
asynchat            heapq               pwd                 uuid
asyncore            hmac                py_compile          warnings
atexit              htmlentitydefs      pycimport           weakref
base64              htmllib             pyclbr              webbrowser
bdb                 httplib             pydoc               whichdb
binascii            ihooks              pydoc_data          wsgiref
binhex              imaplib             pyexpat             xdrlib
bisect              imghdr              quopri              xml
bz2                 imp                 random              xmllib
cPickle             importlib           re                  xmlrpclib
cStringIO           inspect             readline            zipfile
calendar            io                  repr                zipimport
cgi                 isql                rfc822              zlib
cgitb               itertools           rlcompleter         
chunk               jarray              robotparser 

****  以下内容略过 ****

 

查看模块具体使用方法:

help> encodings
Help on package encodings:

NAME
    encodings - Standard "encodings" Package

FILE
    /media/win-share-c/jython-standalone-2.7.2.jar/Lib/encodings/__init__.py

DESCRIPTION
        Standard Python encoding modules are stored in this package
        directory.
    
        Codec modules must have names corresponding to normalized encoding
        names as defined in the normalize_encoding() function below, e.g.
        'utf-8' must be implemented by the module 'utf_8.py'.
    
        Each codec module must export the following interface:
    
        * getregentry() -> codecs.CodecInfo object
        The getregentry() API must a CodecInfo object with encoder, decoder,
        incrementalencoder, incrementaldecoder, streamwriter and streamreader
        atttributes which adhere to the Python Codec Interface Standard.
    
        In addition, a module may optionally also define the following
        APIs which are then used by the package's codec search function:
    
        * getaliases() -> sequence of encoding name strings to use as aliases
    
        Alias names returned by getaliases() must be normalized encoding
        names as defined by normalize_encoding().
    
    Written by Marc-Andre Lemburg (mal@lemburg.com).
    
    (c) Copyright CNRI, All Rights Reserved. NO WARRANTY.

**** 略过部分内容 ****

 

导入模块使用,输入部分后用Tab键显示全部函数(方法):

>>> import encodings
>>> encodings.
encodings.CodecRegistryError(     encodings.__builtin__             encodings.__doc__                 
encodings.__file__                encodings.__loader__              encodings.__name__                
encodings.__package__             encodings.__path__                encodings._aliases                
encodings._cache                  encodings._import_tail            encodings._java                   
encodings._norm_encoding_map      encodings._unknown                encodings.aliases                 
encodings.codecs                  encodings.hex_codec               encodings.idna                    
encodings.normalize_encoding(     encodings.search_function(        encodings.utf_8                   
encodings.__class__(              encodings.__delattr__(            encodings.__dict__                
encodings.__ensure_finalizer__(   encodings.__format__(             encodings.__getattribute__(       
encodings.__hash__(               encodings.__init__(               encodings.__new__(                
encodings.__reduce__(             encodings.__reduce_ex__(          encodings.__repr__(               
encodings.__setattr__(            encodings.__str__(                encodings.__subclasshook__(       

 

 

 

 

 

 

 

 

standalone
posted @ 2021-11-01 08:17  悟透  阅读(192)  评论(0编辑  收藏  举报