动态导入有两种:
1 __main__():
f="demo.A"
aa=__main__(f)
aa.A.t()
2 import importlib:
import importlib
f="demo.A"
aa=importlib.import_module(f)
aa.t()
全局变量使用:
global_list.py:
size=None
A.py:
from demo import global_list
global_list.size=101
from demo.B import *
t()
B.py:
from demo import global_list
de
1