我有以下代碼:不能分配到函數調用(Python)的
class Quadratic:
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
def function(self, x):
self.F(x) = a*(x**2) + b*x + c
return F(x)
def table(self, lower, upper, varz):
inc = np.absolute(upper-lower)/varz
print inc
for i in range(0 , varz - 1):
self.F(lower)
lower = lower + inc
#lower bound,upper bound, number of values
def roots():
x1 = (-b + math.sqrt(b**2 - 4*a*c))/(2*a)
x2 = (-b - math.sqrt(b**2 - 4*a*c))/(2*a)
return x1, x2
def dump(self):
print self.n
每當我嘗試運行此腳本,我得到以下幾點:
line 15
self.F(x) = a*(x**2) + b*x + c
SyntaxError: can't assign to function call
任何幫助或想法將不勝感激。
有什麼解釋?你不能分配給一個函數調用。如果你想***定義一個函數,使用'def'或'lambda'。 – MattDMo 2015-04-01 21:46:56
什麼是'F'?目前還不清楚你想要做什麼。 – frnhr 2015-04-01 21:47:28
什麼是'self.F(x)'? – 2015-04-01 21:49:17