本文實例講述了python實現(xiàn)得到一個給定類的虛函數(shù)的方法,分享給大家供大家參考。具體如下:
現(xiàn)來看看如下代碼:
import wx for method in dir(wx.PyPanel): #這里改成給定的類 if method.startswith("base_"): print method
輸出的結(jié)果為:
base_AcceptsFocusbase_AcceptsFocusFromKeyboardbase_AddChildbase_DoGetBestSizebase_DoGetClientSizebase_DoGetPositionbase_DoGetSizebase_DoGetVirtualSizebase_DoMoveWindowbase_DoSetClientSizebase_DoSetSizebase_DoSetVirtualSizebase_Enablebase_GetDefaultAttributesbase_GetMaxSizebase_InitDialogbase_OnInternalIdlebase_RemoveChildbase_ShouldInheritColoursbase_TransferDataFromWindowbase_TransferDataToWindowbase_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程序設(shè)計有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選