rank vote view answer url
33 1828 3109154 24 url

把字符串解析成浮点数或者整数

在Python里,怎么样把一个数字型字符串像"545.2222"解析成对应的浮点值545.2222?或者把一个"31"解析成31?

我只是想知道怎么样才能解析一个浮点型字符串编程浮点数,或者整型字符串转换成整型?


>>> a = "545.2222"
>>> float(a)
545.22220000000004
>>> int(float(a))
545
Copyright © taizilongxu 2018 all right reserved,powered by Gitbook该文件修订时间: 2018-10-17 17:33:54

results matching ""

    No results matching ""