python environment variable and import module import method of detail

  • 2020-06-12 09:33:01
  • OfStack

1, define,

Module: The essence of a module is the file at the end of.py (logically organizing python code). The essence of a module is to implement a function whose filename is the module name

Packages: 1 with the folder with ___ 7EN__.py; Used to store module files

2. Import module

import module name

form module name import *

from Module Name import Module Name as New name

3. Import module essence

import module name === "assigns all data in the module to the module name. The module name is required when calling.

from module name import method Name == "Put the method into the current file and run it once. When called, only the method name () is needed to run

Import the 1 package with each ___ 34EN__ __ py

The path search

import sys,os

os.path.abspath (___) # gets the full name of the current document

os.path.dirname () # gets the parent directory of the current object

sys.path.insert ()# adds the path of the current object to the first place

sys.path.append () # adds the current environment variable to the end of the environment variable


Related articles: