[英]"Local variable not used" (python3)
Code:代码:
#eg. #例如。 point = (1,2) and eqn = (a,b,c) where the equation is ay+bx+c=0
点 = (1,2) 和 eqn = (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
error:错误:
p_new = round((p*(a**2−b**2)−2*b*(a*q+c))/(a**2+b**2),1)
^
SyntaxError: invalid character in identifier
Q: Why is the character invalid?问:为什么字符无效? When I plug this into pycharm, I also get errors that my #sub values are not being used.
当我将它插入 pycharm 时,我还会收到错误,即我的 #sub 值没有被使用。
The "minus" symbol in your code isn't one, it is Symbole Unicode «−» (U+2212)代码中的“减号”符号不是一个,它是Symbole Unicode «−» (U+2212)
>> ord("−") # yours
8722
>> ord("-") # the real one
45
Fix that and it'll work修复它,它会工作
You should use '-' character as subtraction operator instead of '−'.您应该使用“-”字符作为减法运算符而不是“-”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.