最佳答案
这是每个示例:
from inspect import stack
class Foo:
def __init__(self):
print __file__
print self.__class__.__name__
print stack()[0][3]
f = Foo()
关于python - 如何使用Python获取当前文件,当前类和当前方法?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/894088/