python import from string name 1

python import from string name

import importlib

mod = importlib.import_module(testName)
mod.HelloWorld()

Here is what the above code is Doing:
1. Import the module named testName
2. Get the HelloWorld function from the module
3. Call the HelloWorld function

Similar Posts