"Local variable not used" (python3)



代码:

#例如。点=(1,2(和方程=(a,b,c(,其中方程为ay+bx+c=0

def reflect( point, eqn ):    
#tuples to list
new_p = list(point)
new_eqn = list(eqn)

#sub values
p = new_p[0]
q = new_p[1]
a = new_eqn[0]
b = new_eqn[1]
c = new_eqn[2]

#formula where p'=((a^2−b^2)−2b(aq+c))/a^2+b^2
p_new = round((p*(a**2−b**2)−2*b*(a*q+c))/(a**2+b**2),1)
q_new = round((q*(b**2−a**2)−2*a*(b*p+c))/(a**2+b**2),1)

return p_new,q_new

错误:

p_new = round((p*(a**2−b**2)−2*b*(a*q+c))/(a**2+b**2),1)
^
SyntaxError: invalid character in identifier

Q: 为什么字符无效?当我把它插入pycharm时,我也会收到没有使用#子值的错误。

;减去";代码中的符号不是一个,它是符号Unicode«-»(U+2212(

>> ord("−") # yours
8722
>> ord("-") # the real one
45

修复它,它会工作

应该使用'-'字符作为减法运算符,而不是'-'。

最新更新