--import__("模块名")
导入字符串模块名,然后可以赋值给一个变量
#t.py模块下
def test1():
print("我在这里等你")
def _test2():
print("我是私有属性哦")
#############
#执行函数
module_t = __import__("m1.t") #这样调用得到的是最顶层的m1模块
module_t.t.test1()
对于模块来说,如果被调用的方法前加“-” 变为私有属性后,
from m1.t imoprt * 就不能引入那个方法了
但是可以用
from m1.t import test1,_test2
_test2()
模块定位模块方法
import importlib
m = importlib.import_module("m1.t") #直接拿到t模块
m.test1()
m._test2()