python中,字符串 str 转换成整形 int 中,只能包含数字,不能有其他的。
要先转换成浮点型,再转成整性!
>>> int('12.12')
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
int('12.12')
ValueError: invalid literal for int() with base 10: '12.12'
>>> int('ac')
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
int('ac')
ValueError: invalid literal for int() with base 10: 'ac'
>>> int('12')
12