python--Module Micro-talk

Source: Internet
Author: User

A. py file is a module in which many functions can be defined, and functions can be loaded into a module. Modules also have Python built-in modules, and third-party modules, different modules can have the same function name and variable name, the module can be organized into the package, different package can have the same module name. Note that there must be a __init__.py file under any package, it can play the role of the compiler to identify the package, that is, it is the package!

As in the picture, you can also organize multi-level catalogs, in the MyCompany package, there are several modules in the web package = =, the figure has two __init__.py files, a corresponding Web package, a corresponding MyCompany package. Standard file module for Python modules.
    1. #!/usr/bin/env python3
    2. #coding:utf-8
    3. ‘ a test module‘
    4. _author_=‘Tessie‘
The first line allows the. py file to be used directly on the Mac/linux/unix, and the 2nd line of comments indicates that the. py file itself uses standard UTF-8 encoding, and the third behavior document comment, the first string of any module is the document comment of the module. Line four uses the __author__ variable to write the author in, others can see your name!    ~ Next is the coding section. For private functions and public functions, the private function is the use of this module, do not need to use this function, the private function service inside the module, and the public function can be called externally, that is, the public outside the main, private , which is used to coordinate various functions.

python--Module Micro-talk

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.