Python Method for importing the module by path, python import module
The example in this article describes how to import the python module by path and share it with you for your reference. The specific method is as follows:
The general practice is as follows:
Import sys. path. append ('C:/full/path') from foo import util, bar
But directly through the path
Import imp util = imp. load_source ('util', 'c:/full/path/foo/util. py ')
Util. method is used. At this time, no method is defined.
Method = util. method
I hope this article will help you with Python programming.
The relative path and absolute path of python
From. import ......
From (extension package) import * (* indicates all functions in the extension package, which can also be listed in a single column, for example, from sys import exit)
And directly import xxxx
How to introduce python modules?
Before import, you can
Import sys
Sys. path. append ('your module Directory ') can import the module in this directory.