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中协程的相关问题,具体介绍如下。 Num01–>协程的定义 协程,又称微线程,纤程。英文名Coroutine。 首先我们得知道协程是啥?协程其实可以...

浅谈Python程序与C++程序的联合使用

作为Python程序员,应该能够正视Python的优点与缺点。众所周之,Python的运行速度是很慢的,特别是大数据量的运算时,Python会慢得让人难以忍受。对于这种情况,“专业”的解...

Python基于matplotlib绘制栈式直方图的方法示例

Python基于matplotlib绘制栈式直方图的方法示例

本文实例讲述了Python基于matplotlib绘制栈式直方图的方法。分享给大家供大家参考,具体如下: 平时我们只对一组数据做直方图统计,这样我们只要直接画直方图就可以了。 但有时候我...

django创建简单的页面响应实例教程

django创建简单的页面响应实例教程

首先 编辑views.py文件 每个响应对应一个函数 函数必须返回一个响应 函数必须存在一个参数 一般约定为request 每个响应函数 对应一个URL from django...

Python+django实现文件下载

(1)方法一、直接用a标签的href+数据库中文件地址,即可下载。缺点:word excel是直接弹框下载,对于image txt 等文件的下载方式是直接在新页面打开。 (2)方法二、在...