码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-11-15 13:33:06      阅读:504      评论:0      收藏:0      [点我收藏+]

标签:dir   rtp   usr   star   utf-8   __init__   name   project   ini   

#!/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())

  

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

标签:dir   rtp   usr   star   utf-8   __init__   name   project   ini   

原文地址:https://www.cnblogs.com/ytc6/p/9962511.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!