[root@localhost pythontest]# clear
[root@localhost pythontest]# python
Python 3.6.2 (default, Dec 7 2017, 09:40:15)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'a' is not defined
>>> if a
File "<stdin>", line 1
if a
^
SyntaxError: invalid syntax
>>> if a:
... return a
File "<stdin>", line 2
return a
^
IndentationError: expected an indented block
>>> f=open("a.txt","r")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'a.txt'
>>> print(10/0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
>>> a=int('dd')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: 'dd'
>>>
Python--常见错误
原创
©著作权归作者所有:来自51CTO博客作者飞入闲窗的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Python--错误和异常
一、语法错误print while True:如果错误信息是以SyntaxError开头,这就是说明Pyth
python ico 自定义异常 -
python常见错误类型
Python 学习
Python 常见 异常 类型 -
python 命名常见错误
我一直觉得自己学习了很久的python,常见的错误不
python 命名错误 变量名 编译器