Introduction to the Python module

Source: Internet
Author: User

Modules: Code to implement a function of the code set, functional modularity, save time, improve efficiency

First, the module import

The import module, in fact, tells the Python interpreter to explain the corresponding. py file

• Import the. py file, and the interpreter interprets the. py file

• Pour a package that explains the package under the __init__.py file

To import a module method:

1 Import  Time 2  from Import Sleep 3  from Import Sleep as SP 4  from Import *

The path to the import module, which is Sys.path

1 ImportSYS2 Print(Sys.path)3 4 #The results are as follows5['C:\\users\\lenovo\\pycharmprojects\\ethan\\study_day7','C:\\users\\lenovo\\pycharmprojects\\ethan','C:\\python35\\python35.zip','C:\\python35\\dlls','C:\\python35\\lib','c:\\python35','c:\\python35\\lib\\site-packages']

If you don't have the path you want, use Sys.path.append (' path ') to add

Various catalogs can be obtained through the OS module, such as:

1 Import SYS 2 Import OS 3 4 Pre_path = Os.path.abspath ('./')5#  Print (Pre_path)6 sys.path.append (Pre_path)

Second, the classification of the module
Custom modules: Personal writing, making calls in code you write

Built-in modules: Python official offers

Open Source module: Third-party authoring, open source download installation use

Download the installation method:

12pip3 apt-get
1 Download Source code 2 Decompression Source 3 Go to Catalog 4 compiled source    python setup.py build5 installation source    python setup.py install
Method Two

Introduction to the Python module

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.