Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可以在 python 2.7.3 中获得如下定义的名称:
def Newname(self): print name_of_def > "Newname"
谢谢,
像素
import sys def newname(): print sys._getframe().f_code.co_name newname()
import inspect def Newname(): return inspect.stack()[0][3]
利用__name__
__name__
def Newname(): return 0 print Newname.__name__