2017-07-17 40 views
-2

類父():獲得類型錯誤:對象.__的init __()不帶任何參數

def __int__(self,last_name,eye_color): 
    print("Parent constructor called!") 
    self.last_name=last_name 
    self.eye_color=eye_color 

類孩子(家長): DEF 初始化(個體經營,姓氏,eye_color,number_of_toys): 打印( 「稱爲兒童構造函數」) 父。 INIT(個體,姓氏,eye_color) self.number_of_toys = number_of_toys

miley_cyrus =子( 「古列」, 「藍」,5)

打印(miley_cyrus.last_name) 打印(miley_cyrus.number_of_toys )

越來越

+1

請修復格式。另外,最後一行是什麼(「獲取」)? –

+1

[類初始化失敗]的可能重複(https://stackoverflow.com/questions/44611351/class-initialization-failing) –

回答

1

__int____init__。您定義的方法是將對象轉換爲整數,可以理解爲不接受任何參數。

相關問題