python class 靜態方法

‘’’ 類的靜態方法 ‘’’ class Person(): @staticmethod def shoestyle(): print(‘有無數種’) if name == ‘main’: A = Person A.shoestyle() ‘’’ 使用裝飾器@staticmethod 類裏面的普通函數,不用傳遞self,cls,也可以被對象調用 ‘’’
相關文章
相關標籤/搜索