Token errors in Python will pop up a dialog box like the one below. The message in this box isTabnanny Tokenizing Error. Token Error: EOF in multi-line statement
EOF stands forEnd Of File. This error usually means that there was an open parenthesis somewhere on a line, but not a matching closing parenthesis. Python reached the end of the file while looking for the closing parenthesis.
Example:
a = 3 + (4 + 5
Solution:When you press OK on the dialog box. Python will attempt to highlight the offending line in your source code. However, since it had reached the end of the file, it will highlight the last line in the file! You can type a right parenthesis at the end of the file, and IDLE will highlight the matching opening parenthesis. You should then be able to find out where your missing parenthesis should be. Remember to remove the extra closing parenthesis at the end of your file.
If this doesn't work, you may have to scan your entire file to look for the problem. The best solution is toavoid this problemby running your program after you write every few lines of code. If you encounter this error, you can then check your most recent changes as a likely suspect.
原文链接:http://www.cs.bu.edu/courses/cs108/guides/debug.html
好了以下说人话:
“括号等不匹配”
具体来说是就是:
你的代码中的一行或多行中,括号只输入了一半,而且这一半是右括号。
检查一下你的代码很容易就会发现问题。
看到这你一定会问为什么不是左括号。你可以去掉一段正确的代码中的左括号,运行后会出现如下提示:
最后再多嘴一句:以后遇见括号里面有raw_inpu之类t的,末尾(至少?)要码两个括号!