Sometimes, we want to import module from string variable with Python.
In this article, we’ll look at how to import module from string variable with Python.
How to import module from string variable with Python?
To import module from string variable with Python, we can use the importlib.imnport_module
method.
For instance, we write
import importlib
i = importlib.import_module("matplotlib.text")
to call importlib.import_module
with the module name string to import the module.
Conclusion
To import module from string variable with Python, we can use the importlib.imnport_module
method.