Python--常见错误

[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'
>>>

posted @ 2017-12-07 17:31  王亚锋  阅读(233)  评论(0编辑  收藏  举报