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

相关文章

selenium+python实现自动登陆QQ邮箱并发送邮件功能

selenium+python实现自动登陆QQ邮箱并发送邮件功能

本期做一个selenium详细实例,会把我在元素定位中遇到的一些阻塞和经验分享给大家。 (浏览器为Chrome) (如果只需要最终的完整代码,请直接跳转到文章最后) 浏览器打开QQ邮箱...

Python3实现配置文件差异对比脚本

Python3实现配置文件差异对比脚本

应用场景:配置文件由于升级改动了,我们想看看升级后的配置文件相对于之前的改动了哪些配置项 注意:这个脚本只能检测的配置文件是键值对的形式,就是key=value的形式 我在网上找了好久没...

Django框架反向解析操作详解

Django框架反向解析操作详解

本文实例讲述了Django框架反向解析操作。分享给大家供大家参考,具体如下: 1. 定义: 随着功能的增加会出现更多的视图,可能之前配置的正则表达式不够准确,于是就要修改正则表达式,但是...

Python3.4学习笔记之列表、数组操作示例

本文实例讲述了Python3.4列表、数组操作。分享给大家供大家参考,具体如下: python列表,数组类型要相同,python不需要指定数据类型,可以把各种类型打包进去 python列...

python代码实现逻辑回归logistic原理

python代码实现逻辑回归logistic原理

Logistic Regression Classifier逻辑回归主要思想就是用最大似然概率方法构建出方程,为最大化方程,利用牛顿梯度上升求解方程参数。 优点:计算代价不高,易于...