python study day5

1, the definition module

  Module: used to organize the python code (variable, function, class, logic: implement a function) logically, essentially ending .py python file (file name: the test.py, the corresponding module name: Test)

2, the module use:

   Import module_name

   Import module_name1, module_name2

       From module_alex import * represents all import module module_alex in (not recommended)

  From module_alex import * is introduced All code module_alex

  From module_alex import logger as logger_alex this method can solve the same problem two program name

3, the nature of the import (route search and search path)

       Module_alex = code for all code in the upcoming module_alex explain it again and assign module_alex

       Import module_name --- àmodule_name.py --- à module_name.py path in -àsys.path

 

 

4, the definition of the package

       From module to organize the logic is essentially a directory (file must have the __init__.py)

5, the packet introduced

       The nature of import package is executed inside the package __init__.py file

       You can not import pack_age directly into the package, but may be introduced in the corresponding module __init__.py then import pack_age, so that you can use.

Guess you like

Origin www.cnblogs.com/yunmengchen/p/11222798.html