not callable 表示函數無法調用
我最常遇見的出現該問題的兩種情況:
1 將屬性,當做方法調用
屬性的調用形式:class.attribute
方法的調用形式:class.method(params)
2 方法名與其他屬性、類名重複
例如,下面的代碼中str被定義爲變量,再使用str轉換字符會出現not callable錯誤
str = 'something' x = 1 a = str(x)
not callable 表示函數無法調用
我最常遇見的出現該問題的兩種情況:
1 將屬性,當做方法調用
屬性的調用形式:class.attribute
方法的調用形式:class.method(params)
2 方法名與其他屬性、類名重複
例如,下面的代碼中str被定義爲變量,再使用str轉換字符會出現not callable錯誤
str = 'something' x = 1 a = str(x)