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

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

现来看看如下代码:

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

登录后复制

输出的结果为:

base_AcceptsFocusbase_AcceptsFocusFromKeyboardbase_AddChildbase_DoGetBestSizebase_DoGetClientSizebase_DoGetPositionbase_DoGetSizebase_DoGetVirtualSizebase_DoMoveWindowbase_DoSetClientSizebase_DoSetSizebase_DoSetVirtualSizebase_Enablebase_GetDefaultAttributesbase_GetMaxSizebase_InitDialogbase_OnInternalIdlebase_RemoveChildbase_ShouldInheritColoursbase_TransferDataFromWindowbase_TransferDataToWindowbase_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程序设计有所帮助。

立即学习“Python免费学习笔记(深入)”;

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2291254.html

(0)
上一篇 2025年2月28日 00:53:25
下一篇 2025年2月26日 20:45:45

AD推荐 黄金广告位招租... 更多推荐

相关推荐

发表回复

登录后才能评论