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获取数据库数据并保存在excel表格中的方法

Python获取数据库数据并保存在excel表格中的方法

将数据库中的数据保存在excel文件中有很多种方法,这里主要介绍pyExcelerator的使用。 一、前期准备(不详细介绍MySQL) python包pyExcelerator和MyS...

对python添加模块路径的三种方法总结

之前对mac os系统自带的python进行了升级,结果发现新安装的python的site-packages目录并没有加到python的系统路径中,所以在使用其他库时发现出现了缺少模块的...

pyhton中__pycache__文件夹的产生与作用详解

用python编写了一个工程,但在第一次运行后,发现工程根目录下生成了一个__pycache__文件夹,里面是和py文件同名的各种以.cpython-35.pyc结尾的文件。cpytho...

python 2.7.14安装图文教程

python 2.7.14安装图文教程

本文为大家分享了python2.7.14的安装教程,供大家参考,具体内容如下 1.下载python2.7.14 下载地址 根据自己电脑配置进行选择,我的是win7 64位,所以我选择的...

详解分布式任务队列Celery使用说明

详解分布式任务队列Celery使用说明

起步 Celery 是一个简单、灵活且可靠的,处理大量消息的分布式系统,并且提供维护这样一个系统的必需工具。它是一个专注于实时处理的任务队列,同时也支持任务调度。 运行模式是生产者消费...