也就是什么情况会ValueError?
凑字数:当蜘蛛网无情地尘封了我的烛台……
也就是什么情况会ValueError?
凑字数:当蜘蛛网无情地尘封了我的烛台……
不能转的字串ValueError
复数,列表,集合等 TypeError
>>> int('1.2')
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
int('1.2')
ValueError: invalid literal for int() with base 10: '1.2'
>>> int('a')
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
int('a')
ValueError: invalid literal for int() with base 10: 'a'
>>>
>>> int(1+1j)
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
int(1+1j)
TypeError: can't convert complex to int
>>> int([])
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
int([])
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'
>>> int({1})
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
int({1})
TypeError: int() argument must be a string, a bytes-like object or a number, not 'set'