|
|
1
6
提高
>>> int("a")
Traceback (most recent call last):
File "", line 1, in
ValueError: invalid literal for int() with base 10: 'a'
>>> import shlex; shlex.split("'")
Traceback (most recent call last):
...
ValueError: No closing quotation
把这个和
>>> d = {}
>>> d[{}]
Traceback (most recent call last):
File "", line 1, in
TypeError: unhashable type: 'dict'
|
|
|
2
3
|
|
|
3
2
ValueError可能是最合适的选择。根据它的文档,当一个值具有正确的类型但不适当的值时。 http://docs.python.org/library/exceptions.html#exceptions.ValueError |