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程序设计有所帮助。

相关文章

pycharm 安装JPype的教程

pycharm 安装JPype的教程

配置hanlp 分词器时经常要用jpype,在这里记录一下,pychram 中要成功调用hanlp分词器的过程 我的hanlp 文件已经有了,在hanlp文档中。要把初始路径改为ha...

Python批量生成幻影坦克图片实例代码

Python批量生成幻影坦克图片实例代码

前言 说到幻影坦克,我就想起红色警戒里的…… 幻影坦克(Mirage Tank),《红色警戒2》以及《尤里的复仇》中盟军的一款伪装坦克,盟军王牌坦克之一。是爱因斯坦在德国黑森林中研发的...

使用OpenCV实现仿射变换—平移功能

使用OpenCV实现仿射变换—平移功能

当我们打开一个图片编辑软件时,基本上都会提供几个操作:平移、缩放和旋转。特别目前在手机里拍照时,由于位置传感器的失灵,也许是软件的BUG,有一次我就遇到苹果手机不管怎么样竖放,或横放,它...

分享vim python缩进等一些配置

VIM python下的一些关于缩进的设置: 第一步: 打开终端,在终端上输入vim ~/.vimrc,回车。 第二步: 添加下面的文段: set filetype=p...

解决Django数据库makemigrations有变化但是migrate时未变动问题

解决Django数据库makemigrations有变化但是migrate时未变动问题

写models.py时缺少了一个 verbose_name,导致数据库出现问题,整了很久,摸索出重新建立数据库的方法: 首先删除每个app中的migrations中的除了init.py的...