当使用__import__(),
(嵌套的路径字符串,fromlist=True)
# !/usr/bin/env python # -*- coding:utf8 -*- # import lib.test.com # # r = lib.test.com.com_func() # print(r) ################################### # from lib.test import com # # r1 = com.com_func() # print(r1) ################################### r2 = __import__("lib.test.com", "com_func") print(r2) r3 = __import__("lib.test.com", "com_func", fromlist=True) print(r3)