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

yipeiwu_com6年前Python基础

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

现来看看如下代码:

import wx 

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

输出的结果为:

base_AcceptsFocus
base_AcceptsFocusFromKeyboard
base_AddChild
base_DoGetBestSize
base_DoGetClientSize
base_DoGetPosition
base_DoGetSize
base_DoGetVirtualSize
base_DoMoveWindow
base_DoSetClientSize
base_DoSetSize
base_DoSetVirtualSize
base_Enable
base_GetDefaultAttributes
base_GetMaxSize
base_InitDialog
base_OnInternalIdle
base_RemoveChild
base_ShouldInheritColours
base_TransferDataFromWindow
base_TransferDataToWindow
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程序设计有所帮助。

相关文章

使用python判断jpeg图片的完整性实例

用扩展名判断文件格式非常简单,但是有可能是错误的。 jpeg文件有固定的文件头,其文件头的格式如下: Start Marker | JFIF Marker | Header Leng...

Python综合应用名片管理系统案例详解

Python综合应用名片管理系统案例详解

本文实例讲述了Python综合应用名片管理系统。分享给大家供大家参考,具体如下: 综合应用已经学习过的知识点: 变量 流程控制 函数 模块 开发 名片管理系统 系统需...

Django文件上传与下载(FileFlid)

Django文件上传与下载(FileFlid)

本文实例为大家分享了Django文件上传与下载的具体代码,供大家参考,具体内容如下 Django1.4 首先是上传: #settings.py MEDIA_ROOT = HERE#定义一...

python执行使用shell命令方法分享

1. os.system(shell_command) 直接在终端输出执行结果,返回执行状态0,1 此函数会启动子进程,在子进程中执行command,并返回command命令执行完毕后的...

Python中暂存上传图片的方法

很简单的代码,记录一下。 复制代码 代码如下:     import Image     image = Image.open...