对于此代码,我有"TypeError:/ support支持的操作数类型"
class Foo(object):
def __add__(self, other):
return print("add")
def __div__(self, other):
return print("div")
Foo() + Foo()
add
Run Code Online (Sandbox Code Playgroud)
**但对于/**
Foo() / Foo()
Traceback (most recent call last):
File "<ipython-input-104-8efbe0dde481>", line 1, in <module>
Foo() / Foo()
TypeError: unsupported operand type(s) for /: 'Foo' and 'Foo'
Run Code Online (Sandbox Code Playgroud)