python實現(xiàn)得到一個給定類的虛函數(shù)
本文實例講述了python實現(xiàn)得到一個給定類的虛函數(shù)的方法,分享給大家供大家參考。具體如下:
現(xiàn)來看看如下代碼:
import wx
for method in dir(wx.PyPanel): #這里改成給定的類
if method.startswith("base_"):
print method
輸出的結(jié)果為:
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開頭,函數(shù)返回True.
希望本文所述對大家的Python程序設計有所幫助。
相關文章
python之PyAutoGui教你做個自動腳本計算器的方法

