Python Learning Notes (iii)

Source: Internet
Author: User

Module

The function of a module is to reuse code blocks, such as functions, properties, and classes.

Import Module

The import of a module is imported once, and a. pyc file is generated after the first import, and if it is imported again, Python imports the. pyc file instead of the. py file, unless the. py file has changed, in which case a new. pyc file is generated.

Custom Modules

The custom module is simple, save your own module as a python file at the end of the. Py, put it in a path that the Python interpreter can identify, and we can view the Sys.path path through the

It is customary for us to place the module in the Site-packages directory, and the other is to tell the compiler where to find the module we define, and we can include in the PYTHONPATH environment variable The directory information where the module resides: Edit or create a new user variable in the environment variable's page. The variable is named Pythonpath, the path is a variable value, and multiple values are separated by semicolons.

Package

To organize the modules, you can group them into packages, which are another type of module. In order for Python to treat the directory/file containing the module as a package, it must contain a module named __init__.py.

In order to place the module in the package, put the module directly in the package directory.

Python Learning Notes (iii)

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.