0 basic python-14.1 Python documentation resources: Notes and Dir ()

Source: Internet
Author: User

1. List of document Resources

Form Role
#注释 Documents in the file
Dir function List of available properties in the object
Document string: __doc__ A document near the object
Pydoc:help () Interactive Help for objects
Pydoc:html Report Module documentation in the browser
Standard Manual Formal voice and library instructions
Site Resources Online tutorials, examples, etc.
Published books Business Reference Books

2. Notes

Use the # notation, generally used to illustrate small functions, if the larger type of functionality, generally use the document string

>>> alist=[] #新建一个列表

3.dir ()

Built-in function dir () a simple way to grab all the list of properties available within an object

>>> import sys>>> dir (sys) [' __displayhook__ ', ' __doc__ ', ' __excepthook__ ', ' __interactivehook__ ', ' __loader__ ', ' __name__ ', ' __package__ ', ' __spec__ ', ' __stderr__ ', ' __stdin__ ', ' __stdout__ ', ' _clear_type_cache ', ' _ Current_frames ', ' _debugmallocstats ', ' _getframe ', ' _home ', ' _mercurial ', ' _xoptions ', ' api_version ', ' argv ', ' base_ ' Exec_prefix ', ' base_prefix ', ' builtin_module_names ', ' byteorder ', ' call_tracing ', ' callstats ', ' copyright ', ' Displayhook ', ' dllhandle ', ' dont_write_bytecode ', ' exc_info ', ' excepthook ', ' exec_prefix ', ' executable ', ' exit ', ' Flags ', ' float_info ', ' float_repr_style ', ' getallocatedblocks ', ' getcheckinterval ', ' getdefaultencoding ', ' Getfilesystemencoding ', ' getprofile ', ' getrecursionlimit ', ' getrefcount ', ' getsizeof ', ' getswitchinterval ', ' Gettrace ', ' getwindowsversion ', ' hash_info ', ' hexversion ', ' implementation ', ' int_info ', ' Intern ', ' maxsize ', ' Maxunicode ', ' meta_path ', ' modules ', ' path ', ' path_hooks ', ' path_importer_cache ', ' platform ', ' prefix', ' setcheckinterval ', ' setprofile ', ' setrecursionlimit ', ' setswitchinterval ', ' settrace ', ' stderr ', ' stdin ', ' stdout '  , ' Thread_info ', ' Version ', ' Version_info ', ' warnoptions ', ' winver ']>>>

If you need to find out the properties and methods provided by the object, we can pass in an empty object, such as:

>>> dir (()) [' __add__ ', ' __class__ ', ' __contains__ ', ' __delattr__ ', ' __dir__ ', ' __doc__ ', ' __eq__ ', ' __format_ _ ', ' __ge__ ', ' __getattribute__ ', ' __getitem__ ', ' __getnewargs__ ', ' __gt__ ', ' __hash__ ', ' __init__ ', ' __iter__ ', ' __le_ _ ', ' __len__ ', ' __lt__ ', ' __mul__ ', ' __ne__ ', ' __new__ ', ' __reduce__ ', ' __reduce_ex__ ', ' __repr__ ', ' __rmul__ ', ' __ Setattr__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ', ' count ', ' Index ']>>> dir ([]) [' __add__ ', ' __class__ ' , ' __contains__ ', ' __delattr__ ', ' __delitem__ ', ' __dir__ ', ' __doc__ ', ' __eq__ ', ' __format__ ', ' __ge__ ', ' __getattribute __ ', ' __getitem__ ', ' __gt__ ', ' __hash__ ', ' __iadd__ ', ' __imul__ ', ' __init__ ', ' __iter__ ', ' __le__ ', ' __len__ ', ' __lt__ ', ' __mul__ ', ' __ne__ ', ' __new__ ', ' __reduce__ ', ' __reduce_ex__ ', ' __repr__ ', ' __reversed__ ', ' __rmul__ ', ' __setattr__ ', ' __setitem__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ', ' append ', ' clear ', ' copy ', ' Count ', ' extend ', ' index ', ' Insert ', ' pop ', ' remove ', ' reverse ', ' sort ']>>>Dir (') [' __add__ ', ' __class__ ', ' __contains__ ', ' __delattr__ ', ' __dir__ ', ' __doc__ ', ' __eq__ ', ' __format__ ', ' __ge__ ', ' __getattribute__ ', ' __getitem__ ', ' __getnewargs__ ', ' __gt__ ', ' __hash__ ', ' __init__ ', ' __iter__ ', ' __le__ ', ' __len__ ' , ' __lt__ ', ' __mod__ ', ' __mul__ ', ' __ne__ ', ' __new__ ', ' __reduce__ ', ' __reduce_ex__ ', ' __repr__ ', ' __rmod__ ', ' __rmul__ ' , ' __setattr__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ', ' capitalize ', ' casefold ', ' center ', ' count ', ' encode ', ' EndsWith ', ' expandtabs ', ' find ', ' format ', ' Format_map ', ' index ', ' isalnum ', ' isalpha ', ' isdecimal ', ' isdigit ', ' Isidentifier ', ' islower ', ' isnumeric ', ' isprintable ', ' isspace ', ' istitle ', ' isupper ', ' join ', ' ljust ', ' lower ', ' Lstrip ', ' Maketrans ', ' partition ', ' replace ', ' rfind ', ' rindex ', ' rjust ', ' rpartition ', ' rsplit ', ' Rstrip ', ' Split ', ' SPL  Itlines ', ' startswith ', ' strip ', ' swapcase ', ' title ', ' Translate ', ' upper ', ' Zfill ']>>>

Or we can pass the name of the object:


Summary, this chapter mainly lists the documentation resources, and briefly explains the comments and the Dir function


This chapter is here, thank you.

------------------------------------------------------------------

Click to jump 0 basic python-Catalogue



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

0 Basic python-14.1 Python documentation resources: Comments and Dir ()

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.