CONTENT
- 1 语法类
- 2 变量类
- 3 习惯类
1 语法类
1.1 忘记结束符号
有些符号需要结束符号。比如:()、<>
、''
和""
等。
下面是一些错误的例子:
print("Hello, world! "
print("Hello, %s" % ("Python")
日志:
Syntax error: invalid syntax
2 变量类
2.1 全局变量忘记声明
错误示例:
def say(Value):
print(N, "说: ", Value);
N += 2;
N = 1;
say(31);
日志:
Name: 2
Traceback (most recent call last):
File "C:\Users\ADMINI~1\AppData\Local\Temp\codemao-krGcPK/temp.py", line 7, in <module>
say(input("Name: "))
File "C:\Users\ADMINI~1\AppData\Local\Temp\codemao-krGcPK/temp.py", line 2, in say
print(N, "说: ", Value)
UnboundLocalError: local variable 'N' referenced before assignment
3 习惯类
例子:
print "hello"
日志:
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("hello")?