Use exec
:
exec 'import vfs_tests as v'
eval
works only on expressions, import
is a statement.
exec
is a function in Python 3 : exec('import vfs_tests as v')
To import a module using a string you should use importlib
module:
import importlib
mod = importlib.import_module('vfs_tests')
In Python 2.6 and earlier use __import__
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…