且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python-TypeError:“ int”对象不可调用

更新时间:2022-06-11 04:04:00

在第一类中,总计 是该类的函数和属性。那不行:) Python认为您在最后一行中引用的总数是整数变量total而不是函数。

In the first class total is a function as well as an attribute of the class. That is not okay :) Python thinks that the total you are referring to in the final line is the integer variable total and not the function.

这被认为是一种好习惯将函数 total 命名为 get_total 代替

It is considered a good practice to name the function total as get_total instead