Python2-Base 2

Source: Internet
Author: User

One, the Python module

The power of Python is that he has a very rich and powerful library of standards and third-party libraries , and almost any feature you want to implement has the appropriate Python library support

The Python module, which is a python file that ends with a. Py, contains Python object definitions and Python statements.

Use a module to avoid conflicting function names and variable names. Functions and variables of the same name can exist in separate modules

The modules are divided into three types:

    • built-in modules : sys, OS, subprocess, time, JSON, etc.
    • Custom Modules : When customizing a module, be careful about naming it and not conflict with the module name that comes with Python. For example, the system comes with a sys module, its own module can not be named sys.py , or you will not be able to import the system's own sys module.
    • Open Source Modules : Public third-party modules, such as Https://pypi.python.org/pypi. Can be installed using PIP install, similar to Yum installation software

>>> Help (' modules ')

See all modules in Python

Import Statement

Once the module is well defined, we can use the import statement to introduce the module with the following syntax:

import module1[, module2[,... Modulen]

When you invoke a function in a module, you must refer to this: module name. function name

When the interpreter encounters an import statement, the module is imported if it is in the current search path.

A search path is a list of all directories that an interpreter will search first. To import the module support.py, you need to place the command at the top of the script:

Module name. function name

Python2-Base 2

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.