0
点赞
收藏
分享

微信扫一扫

ValueError: invalid literal for int() with base 10: ‘10.3‘解决办法

双井暮色 2022-04-25 阅读 75
python
print(type(int('10.3')))

报错如上

原因:int不能够把带小数的字符串转为int型。需要先转化为float型

print(type(int(float('10.3'))))

 就可以了

举报

相关推荐

0 条评论