我正在学习Python,但我无法找到答案:
"实现add方法。它应该向当前字段添加金额。"
class Complex:
def create(self, real_part, imag_part):
self.r = real_part
self.i = imag_part
class Calculator:
current = 0
def add(self, amount):
*i need to edit only this line*
def get_current(self):
return self.current
答案 0 :(得分:0)
你可以这样做:
def add(self, amount):
self.current += amount