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

python獲取函數名類名

系統 1911 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條評論
主站蜘蛛池模板: 梧州市| 乌鲁木齐县| 黔南| 武邑县| 鄄城县| 桑日县| 德阳市| 台山市| 衡阳市| 额尔古纳市| 瑞安市| 芦溪县| 朔州市| 易门县| 大庆市| 简阳市| 武乡县| 建阳市| 西安市| 余姚市| 怀集县| 阜新| 临城县| 合肥市| 民县| 芒康县| 富川| 福海县| 三河市| 运城市| 洛浦县| 阿克| 和平区| 班玛县| 正安县| 长宁县| 伊金霍洛旗| 石首市| 遵化市| 泾川县| 鄄城县|