2
我在python中使用math.sqrt来计算东西的squre根,但是“something”是一个符号而不是已知的值。我使用这个“东西”作为后期使用的中间变量。我怎样才能在python中获得符号的平方根?
import math
from math import sqrt
x = Symbol('x')
y = math.sqrt(x)
print(y)
豪尔我得到错误信息
File "/Library/Python/2.7/site-packages/sympy/core/expr.py", line 207, in __float__
raise TypeError("can't convert expression to float")
TypeError: can't convert expression to float
貌似有没有其他的包,我计算平方根除“math.sqrt”,没有人知道我怎么能摆脱这个问题的?
这不应该关闭。用户正在使用名为sympy的库。我建议用户应该更新问题以明确Symbol()来自该库;这将清除混乱。 – BobbyShaftoe 2014-09-13 02:53:52