class Test:
def __init__(self,name):
self.name=name
def __add__(self, other):
return self.name + '+' +other.name
def __lt__(self, other):#<的重载
return '<<<'
def __str__(self):
return self.name*3
def __len__(self):
return 50
a=Test('a')
b=Test('b')
print(a+b)
print(a
输出:
a+b
<<<
aaa
50



