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

yipeiwu_com5年前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实现115网盘自动下载的方法

本文实例讲述了Python实现115网盘自动下载的方法。分享给大家供大家参考。具体实现方法如下: 实例中的1.txt,是网页http://bbs.pediy.com/showthread...

python 在指定范围内随机生成不重复的n个数实例

python 在指定范围内随机生成不重复的n个数实例

利用Python中的randomw.sample()函数实现 resultList=random.sample(range(A,B),N); #表示从[A,B]间随机生成N个数,结...

python matplotlib中文显示参数设置解析

python matplotlib中文显示参数设置解析

最近在学习python著名的绘图包matplotlib时发现,有时候图例等设置无法正常显示中文,于是就想把这个问题解决了。 PS:本文仅针对Windows,其他平台仅供参考。 原因 大致...

使用python快速实现不同机器间文件夹共享方式

Python有一个比较好用的功能,那就是很方便的实现共享文件夹。 首先两台主机都需要安装python,在未建立逻辑连接之前它们是不区分主从机的。 例如:现在有两台机器,一台windows...

python非递归全排列实现方法

刚刚开始学习python,当前看到了函数这一节。结合数组操作,写了个非递归的全排列生成。原理是插入法,也就是在一个有n个元素的已有排列中,后加入的元素,依次在前,中,后的每一个位置插入,...