输入类型不支持ufunc'bitwise_or'

问题描述 投票:-2回答:1

我正在尝试根据以下方程式制作“ matplotlib”图:q(x)=(x ** 2)/(x + 1)

我尝试过此代码:


def r(x):
    return (x*x) / (x+1)

while x<= -2 | x >= 0:
    pylab.plot(x, r(x), color = 'r--')

向我显示错误:


TypeError                                 Traceback (most recent call last)
<ipython-input-14-387fb2375bb1> in <module>
      2     return (x*x) / (x+1)
      3 
----> 4 while x<= -2 | x >= 0:
      5     pylab.plot(x, r(x), color = 'r--')

TypeError: ufunc 'bitwise_or' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

我是python机器学习的新手,所以我对如何调试它知之甚少。

感谢您的帮助!

python machine-learning bitwise-operators
1个回答
0
投票

[|是按位或运算符-您应该仅使用or关键字作为逻辑替代。

Read further

© www.soinside.com 2019 - 2024. All rights reserved.