how to import a module with a string?

import importlib

mymodule = importlib.import_module('matplotlib.text')

Here is what the above code is Doing:
1. importlib.import_module() is a function that takes a string and returns a module.
2. The string ‘matplotlib.text’ is the name of the module we want to import.
3. The module is returned by importlib.import_module() and assigned to the variable mymodule.
4. We can now use the module as we would any other module.