Python Path-modules

Source: Internet
Author: User
Definition: Used to logically organize Python code, essentially a python file with a. py suffix (file name: test.py, corresponding module name: Test) Import Method:
  • Importing a module: Import module_name
  • Import multiple modules (comma-separated module names): Import Module1_name,module2_name ...
  • Import all variables and methods in the module: from module_name Import *
  • Import a variable or method in the module and give it an alias: from module_name import func_name as New_func_name >>> the system will run with New_func_name under the current file func_ Name function (Note: The Import function only writes the function name without parentheses)
  • Import several variables or methods in the module: from module_name import m1,m2,m3 ...
The essence of the import module is that the import module essentially runs through all the code in the imported module and returns the run result to the module name. Therefore, in the file that imports the module, the module name can be used to import variables and functions in a module by using the variable and method in the import module by the dot operator: Importing a variable or function in a module essentially runs the import variable or function and assigns their return value to the imported variable or functions name

Python Path-modules

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.