我想添加到我的类的实例中Bar:
x = Bar([5, 12, 5])
y = Bar([4, 5, 6])
x+y #Bar([9, 17, 11])
Run Code Online (Sandbox Code Playgroud)
这是班级:
class Bar:
def __init__(self, arr):
self.items = arr
def __repr__(self):
return "Bar("+str(self.items)+")"
Run Code Online (Sandbox Code Playgroud)