Import python module NOT on path
http://stackoverflow.com/questions/10161568/import-python-module-not-on-path
常规做法:
[python] view plain copy
- import sys
- sys.path.append(‘C:/full/path‘)
- from foo import util,bar
而要直接通过路径
[python] view plain copy
- import imp
- util = imp.load_source(‘util‘, ‘C:/full/path/foo/util.py‘)
使用时使用util.method,此时并没有定义method
method
= util.method后才可以直接用method
时间: 2024-11-12 09:48:39