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

相关文章

windows系统下Python环境搭建教程

windows系统下Python环境搭建教程

windows系统下Python环境的搭建 step1:下载Python程序 https://www.python.org/downloads/release/python-351/...

python验证码识别教程之利用滴水算法分割图片

python验证码识别教程之利用滴水算法分割图片

滴水算法概述 滴水算法是一种用于分割手写粘连字符的算法,与以往的直线式地分割不同 ,它模拟水滴的滚动,通过水滴的滚动路径来分割字符,可以解决直线切割造成的过分分割问题。 引言 之前提过对...

Python字符串处理实例详解

Python字符串处理实例详解 一、拆分含有多种分隔符的字符串 1.如何拆分含有多种分隔符的字符串 问题: 我们要把某个字符串依据分隔符号拆分不同的字段,该字符串包含多种不同的分隔符,例...

Eclipse中Python开发环境搭建简单教程

Eclipse中Python开发环境搭建简单教程

一、背景介绍   Eclipse是一款基于Java的可扩展开发平台。其官方下载中包括J2EE方向版本、Java方向版本、C/C++方向版本、移动应用方向版本等诸多版本。除此之外,Ecli...

完美解决python中ndarray 默认用科学计数法显示的问题

完美解决python中ndarray 默认用科学计数法显示的问题

机器环境: Python 3.6.4 numpy==1.14.0 pandas==0.22.0 解决方法: np.set_printoptions(suppress=True) 默认情况...