日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

python獲取函數名類名

系統 1880 0

參考鏈接:

1.在類內部獲取類名和方法名

代碼:

            
              import sys


class testsqawd(object):
    def hello(self):
        print('the name of method is ## {}##'.format(sys._getframe().f_code.co_name))
        print('the name of class is ## {} ##'.format(self.__class__.__name__))


if __name__ == '__main__':
    ttt = testsqawd()
    ttt.hello()

            
          

運行結果:

            
              the name of method is ## hello ##
the name of class is ## testsqawd ##

Process finished with exit code 0
            
          

2.函數內部獲取函數名

            
              def my_name():
    print(sys._getframe().f_code.co_name)
    print(inspect.stack()[0][3])

            
          

?


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 隆德县| 新密市| 讷河市| 林口县| 泽普县| 弥勒县| 全州县| 循化| 昆明市| 云龙县| 黔西| 吉木萨尔县| 德钦县| 苏州市| 沐川县| 朝阳区| 隆昌县| 彰化市| 山阳县| 柳江县| 温泉县| 德江县| 富宁县| 宣武区| 扎兰屯市| 景泰县| 中山市| 铜山县| 普洱| 东宁县| 北川| 新沂市| 民权县| 云和县| 乐业县| 东乌珠穆沁旗| 湖北省| 安顺市| 屏边| 申扎县| 松滋市|