当前位置:主页 > 软件编程 > Python代码 >

Python 字符串转换为整形和浮点类型的方法

时间:2021-03-16 10:19:50 | 栏目:Python代码 | 点击:

Python2.6 之前:字符串转换为整形和浮点型

>>>import string

>>>string.atoi('34.1')

34

>>>string.atof(‘34.1')

34.1

python2.6之后:字符串转换为整形和浮点型

>>>import string

>>>int('34.1')

34

>>>float('34.1')

34.1

您可能感兴趣的文章:

相关文章