欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

python 获取类中除内置方法外的所有方法名

程序员文章站 2022-03-26 13:29:52
#!/usr/bin/env python# !-*- coding:utf-8 -*-class Menu: def __init__(self): pass def updateProject(self): pass def restartProject(self): pass def rest... ......
#!/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())