这样相加的话代码要怎么写?
class Rational(object): def __init__(self, aa, bb, cc): self.aa = aa self.bb = bb self.cc = cc def __add__(self,x): return a1 = Rational(1, 3, 4) a2 = Rational(1, 2, 3) a3 = Rational(2, 5, 7)
请问a1 + a2 + a3在__add__中相加要怎么写?
class Rational(object): def __init__(self, aa, bb, cc): self.aa = aa self.bb = bb self.cc = cc def __add__(self,x): return a1 = Rational(1, 3, 4) a2 = Rational(1, 2, 3) a3 = Rational(2, 5, 7)
请问a1 + a2 + a3在__add__中相加要怎么写?
2018-07-19
举报