从另一个py文件中的列表(字符串)调用函数

call function from list(string) in another py file

我有 3 个 python 脚本 ('testPrint01.py','testPrint02.py','testPrint03.py') 我想从 'testPrint02'

调用函数
    import sys
    sys.path.append(path)

    a = ['testPrint01','testPrint02','testPrint03']
    import sys.a[1]
    a[1].justPrintIt()

谢谢

如果您与目标脚本位于同一目录中,则可以使用

from testPrint02 import x

其中 x 是您要导入的函数。

编辑: 要从字符串变量导入模块,您可以使用 importlib,如下所述:import module from string variable