Python Foundation-python most important, library/module

Source: Internet
Author: User


Niche Blog:http://xsboke.blog.51cto.com

Niche Q q:1770058260

------- Thank you for your reference, if you have any questions, please contact


I. Introduction of the Module

1. Concept

  • a code set consisting of N. py files is called a module for the implementation of complex functions

  • The module is a file

  • Dir(module name): You can see how the module is used

2. Classification

  • custom modules, built-in modules, third-party modules (http://pypi.python.org)

3. Import the module

  • The import module is actually telling The Python interpreter interprets the py file,imports the module name into a py file, the interpreter interprets the py file or imports a package, and the interpreter interprets the __ in the package. init__.py file.

1) from module name . Xx.xximport XX

2) from module name . xx.xximport xx as alias

3) from module name . Xx.xximport *

4. Installation process of open source module

1) Download the source code

2) unzip the source code

3) Enter the catalogue

4) Compile the source python setup.py build(This command is not normally required now)

5) Install the source python setup.py install

Os module: Used to provide system-level operations

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/97/3D/wKiom1krkl6Qze3gAAEvHsDYI0c204.png "title=" Image002.png "alt=" Wkiom1krkl6qze3gaaevhsdyi0c204.png "/>

III. SYS module: Provides an interpreter-related operation

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/97/3D/wKiom1krknuRYrJ9AABiRSNksxs845.png "title=" Image003.png "alt=" Wkiom1krknuryrj9aabirsnksxs845.png "/>

Four, Shutil module: Advanced Processing file Module

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/97/3E/wKioL1krkpei9LK_AACh8AIXWMs467.png "title=" Image004.png "alt=" Wkiol1krkpei9lk_aach8aixwms467.png "/>

V. python2.+ compression using zipfile and tarfile modules

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/97/3E/wKioL1krkrTwj2YlAAA0IzGby_U268.png "style=" float : none; "title=" Image005.png "alt=" Wkiol1krkrtwj2ylaaa0izgby_u268.png "/>

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/97/3E/wKioL1krkrTx9MmTAABByBUgyCY479.png "style=" float : none; "title=" Image006.png "alt=" Wkiol1krkrtx9mmtaabbybugycy479.png "/>

VI. Random module: Used to generate stochastic numbers

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/97/3D/wKiom1krktyShSTpAAA40htLe8M855.png "title=" Image007.png "alt=" Wkiom1krktyshstpaaa40htle8m855.png "/>

Vii. MD5 and hashlib cryptographic modules: can be used to generate ciphertext for strings

1. MD5(3.X version integrated into the hashlib )

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/97/3E/wKioL1krkvjRUct0AAFVFEPTwj8423.jpg "title=" Image008.jpg "alt=" Wkiol1krkvjruct0aafvfeptwj8423.jpg "/>

  • As can be seen here,MD5 can be plaintext encryption, can be used for password authentication, for example, the user's real password is saved with passwd defined as 123456, and then the user log onwhen the user login password use password definition, if the password entered is correct, the last comparison of two ciphertext is the same.

2. Hashlib module: Support more encryption than MD5

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/97/3D/wKiom1krkyyzvA3SAABiXa_g6qw249.jpg "title=" Image009.jpg "alt=" Wkiom1krkyyzva3saabixa_g6qw249.jpg "/>

They are used in a similar way

Eight, re modules: support Regular Expressions

1. Match,search,findall

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/97/3D/wKiom1krk02g8AgqAACFcC458Ls126.png "title=" Image010.png "alt=" Wkiom1krk02g8agqaacfcc458ls126.png "/>

2. When matching a large number of rows, use this method

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/97/3E/wKioL1krk17j_FqGAACA0qxLwkQ899.png "title=" Image011.png "alt=" Wkiol1krk17j_fqgaaca0qxlwkq899.png "/>

3. use of Sub,split,FindAll

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/97/3E/wKioL1krk2vgZPcLAABy4hpsuFQ878.png "title=" Image012.png "alt=" Wkiol1krk2vgzpclaaby4hpsufq878.png "/>

4. Regular expressions

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/97/3D/wKiom1krk3uDvc4uAAHwAzVpCmE726.png "title=" Image013.png "alt=" Wkiom1krk3udvc4uaahwazvpcme726.png "/>

5. Shelve module:python A simple storage data solution

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/97/3E/wKioL1krk46wY84kAABeaTQnwwc529.png "title=" Image014.png "alt=" Wkiol1krk46wy84kaabeatqnwwc529.png "/>

Ten, Time module: shows the elapsed times from that to present, which can be used to calculate elapsed time or display the current time

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/97/3D/wKiom1krk5zjEs9ZAABqxRukjrk602.png "style=" float : none; "title=" Image015.png "alt=" Wkiom1krk5zjes9zaabqxrukjrk602.png "/>

650) this.width=650; "src=" https://s3.51cto.com/wyfs02/M00/97/3E/wKioL1krk5yin2RdAADP-iuq-t4184.jpg "style=" float : none; "title=" image016.jpg "alt=" Wkiol1krk5yin2rdaadp-iuq-t4184.jpg "/>


This article is from the "Niche blog" blog, please be sure to keep this source http://xsboke.blog.51cto.com/12096269/1930550

Python Foundation-python most important, library/module

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.