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提取具有某种特定字符串的行数据方法

python提取具有某种特定字符串的行数据方法

今天又帮女朋友处理了一下,她的实验数据,因为python是一年前经常用,最近找工作,用的是c,c++,python的有些东西忘记了,然后就一直催我,说我弄的慢,弄的慢,你自己弄啊,烦不烦...

python字符串反转的四种方法详解

这篇文章主要介绍了python字符串反转的四种详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 1、用reduce函数方法 b...

python统计文本字符串里单词出现频率的方法

本文实例讲述了python统计文本字符串里单词出现频率的方法。分享给大家供大家参考。具体实现方法如下: # word frequency in a text # tested wit...

一百行python代码将图片转成字符画

一百行python代码将图片转成字符画

本文实例为大家分享了python将图片转成字符画的具体代码,供大家参考,具体内容如下 该代码引用了PIL库的Image,所以必须先安装PIP,再安装PIL,记住,我的64位系统居...

使用Django开发简单接口实现文章增删改查

使用Django开发简单接口实现文章增删改查

1、一些准备工作  安装django pip install django 创建django项目 进入项目代码存放目录执行命令: django-admin.py st...