python 獲取類中除內置方法外的所有方法名


#!/usr/bin/env python
# !-*- coding:utf-8 -*-

class Menu:

def __init__(self):
pass

def updateProject(self):
pass

def restartProject(self):
pass

def restartTomcat(self):
pass

def stopTomcat(self):
pass

def startTomcat(self):
pass

def methods(self):
return(list(filter(lambda m: not m.startswith("__") and not m.endswith("__") and callable(getattr(self, m)), dir(self))))

if __name__ == '__main__':
print(Menu().methods())

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM