3 help functions in Python help,dir,type using __ function

Source: Internet
Author: User
Tags package json

1 Help function: View modules, functions, variables detailed description:

View Module

>>> Help ("modules")

moment the while I gather a list of all available modules

... Basehttpserver      Array               htmllib             sets
Bastion             ast
httplib               sgmllib CDROM Asynchat            ihooks              sha
cgihttpserver       asyncore
imaplib              shelve Canvas Atexit              imghdr              shlex
configparser        audiodev            imp                 shutil
Cookie              audioop             importlib           signal
DLFCN               axi                 imputil             site
Dialog              Base64 Inspect             sitecustomize
Docxmlrpcserver     bdb                 io                  smtpd
filedialog          binascii           itertools


View Package

>>> help (' JSON ') Help on
package JSON:

NAME
    json

FILE
    /usr/lib/python2.7/json/__init_ _.py

MODULE DOCS
    http://docs.python.org/library/json

DESCRIPTION
    json (JavaScript Object notation) 


View class

>>> Help (JSON. Jsondecoder) Help on
class Jsondecoder in module Json.decoder:

class Jsondecoder (__builtin__.object)
 |  Simple JSON 


To view functions:

>>> Help (Json.dump) Help
on function dump in module JSON:

dump (obj, FP, Skipkeys=false, ensure_ascii= True, Check_circular=true, Allow_nan=true, Cls=none, Indent=none, Separators=none, encoding= ' Utf-8 ', default=None, * * kw)
    Serialize ' obj ' as a JSON formatted stream to ' FP ' (a
    '. Write () '-supporting File-like object).
    
    If ' Skipkeys ' is true Then ' dict ' the keys that are not basic types
    (' str ', ' Unicode ', ' int ', ' ', ' ', ' ' ', ' bool ', ' None '] would be
    skipped instead of raising a ' typeerror '.
    
    If ' Ensure_ascii ' is false, then the some chunks written to ' ' FP ' ' ' could
    ' ' Unicode ' instances, subject to normal P Ython ' str ' to ' '
    Unicode ' coercion rules. Unless ' fp.write () ' Explicitly
    understands ' Unicode ' (as in ' Codecs.getwriter () ')
    Cause an error.


2 dir function: View functions or methods available to variables

>>> Import sys >>> dir (sys) [' __displayhook__ ', ' __doc__ ', ' __excepthook__ ', ' __name__ ', ' __package__ ', ' __stderr__ ', ' __stdin__ ', ' __stdout__ ', ' _clear_type_cache ', ' _current_frames ', ' _getframe ', ' _mercurial ', ' Api_ Version ', ' argv ', ' builtin_module_names ', ' byteorder ', ' call_tracing ', ' callstats ', ' copyright ', ' displayhook ', ' Dont_ Write_bytecode ', ' exc_clear ', ' exc_info ', ' exc_type ', ' excepthook ', ' exec_prefix ', ' executable ', ' exit ', ' exitfunc ', ' Flags ', ' float_info ', ' float_repr_style ', ' getcheckinterval ', ' getdefaultencoding ', ' getdlopenflags ', ' Getfilesystemencoding ', ' getprofile ', ' getrecursionlimit ', ' getrefcount ', ' getsizeof ', ' gettrace ', ' hexversion ', ' Last_traceback ', ' last_type ', ' last_value ', ' long_info ', ' maxint ', ' maxsize ', ' maxunicode ', ' meta_path ', ' modules ', ' Path ', ' path_hooks ', ' path_importer_cache ', ' platform ', ' prefix ', ' ps1 ', ' ps2 ', ' py3kwarning ', ' pydebug ', ' Setcheckinterval ', ' setdlopenflags ', ' setprofile ', ' setrecursionlimit ', ' settrace ', ' stdErr ', ' stdin ', ' stdout ', ' subversion ', ' Version ', ' Version_info ', ' warnoptions ' 


3 type function: Viewing the type of a variable

<type ' module ' >
>>> type (json.__name__)
<type ' str ' >
>>> type ( Json.decoder)
<type ' module ' >

4 Exit Python command line

WINDOWS:CTRL+Z Carriage return

Linux:ctrl+d

Note: Use Pydoc module to view document descriptions for modules

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.