当前位置:Gxlcms > Python > python实现得到一个给定类的虚函数

python实现得到一个给定类的虚函数

时间:2021-07-01 10:21:17 帮助过:63人阅读

本文实例讲述了python实现得到一个给定类的虚函数的方法,分享给大家供大家参考。具体如下:

现来看看如下代码:

  1. import wx
  2. for method in dir(wx.PyPanel): #这里改成给定的类
  3. if method.startswith("base_"):
  4. print method

输出的结果为:

  1. base_AcceptsFocus
  2. base_AcceptsFocusFromKeyboard
  3. base_AddChild
  4. base_DoGetBestSize
  5. base_DoGetClientSize
  6. base_DoGetPosition
  7. base_DoGetSize
  8. base_DoGetVirtualSize
  9. base_DoMoveWindow
  10. base_DoSetClientSize
  11. base_DoSetSize
  12. base_DoSetVirtualSize
  13. base_Enable
  14. base_GetDefaultAttributes
  15. base_GetMaxSize
  16. base_InitDialog
  17. base_OnInternalIdle
  18. base_RemoveChild
  19. base_ShouldInheritColours
  20. base_TransferDataFromWindow
  21. base_TransferDataToWindow
  22. base_Validate

另附一个常用的str的方法,官方文档如下:
str.startswith(prefix[,start[,end]])

Return True if string starts with theprefix, otherwise returnFalse.prefix can also be a tuple of prefixes to look for. With optionalstart, test string beginning at that position. With optionalend, stop comparing string at that position.

如果string以prefix开头,函数返回True.

希望本文所述对大家的Python程序设计有所帮助。

人气教程排行