如何获取导入我的文件的名称?

时间:2018-01-02 18:29:27

标签: python import python-import

让我们假设有模块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.pyB.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()函数的东西,它获取导入我的模块的名称(假设我是模块)?

0 个答案:

没有答案