1. Define the module: The essence is. py file (logically organized Python code) The essence of the module is to implement a function filename is the module name package: a folder with __init__.py; to store module files 2. Importing module import module Name form module name Import * from module name import module name as new name 3. Import module Essential Import Module NAME = = = The module name is assigned to all data in the module, and the module name is required when calling. Method Name () from Module name Import method name = = "Put this method in the current file to run once, call only the method name () to run the import of a package is to execute the package The __init__.py file path under the search for import Sys,osos.path.abspath (__file__) #获取当前文件的全名os. Path.dirname () #获取当前对象的父级目录sys. Path.insert () #将当前对象的路径添加到首位sys. Path.append () # Add the current environment variable to the end of the environment variable
Python Day05 python environment variables and import module imports