【Python】ValueError: invalid literal for int() with base 10的错误

###Date: 2018/1/4
###Author: SoaringLee
====================================================================

问题:


>>>int('1.5')ValueError: invalid literal forint() with base10:'1.5'

原因:


因为python假设需要进行int转型的字符串仅仅包含数字,去除掉字符串中的非数字字符即可。

参考:

https://stackoverflow.com/questions/1841565/valueerror-invalid-literal-for-int-with-base-10
http://blog.csdn.net/ikerpeng/article/details/17316193#reply
http://blog.csdn.net/tao_627/article/details/44274543

你可能感兴趣的:(【Bugfix,Tips】,【编程语言之Python】,【Python编程】)