小编jfb*_*eux的帖子

TypeError:/不支持的操作数类型:

对于此代码,我有"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)

python generator

3
推荐指数
1
解决办法
3697
查看次数

标签 统计

generator ×1

python ×1