假设有A,B,C模块:
A.py
import C
# do stuff
B.py
import C
# do stuff
C.py
print( "I am the C module and I am being imported by " + get_importer_name() )
当运行A.py
或B.py
时,输出将是:
I am the C module and I am being imported by A
I am the C module and I am being imported by B
是否存在类似于get_importer_name()
函数的东西,该函数获取导入我的模块的名称(假设我是一个模块)?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐