码迷,mamicode.com
首页 > 编程语言 > 详细

Python 字符串 转换 整数 浮点数 数字

时间:2014-12-01 22:35:40      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:style   ar   使用   sp   on   as   line   size   python   

使用PyOpengl的时候,调用glVertex2f时,传入两个字符串会报错,所以需要将字符串转为浮点数再传,可以使用下面的方法。

>>> import string

>>> string.atoi('34')
34
>>> int('34')
34
>>> string.atof('34')
34.0
>>> float('34')
34.0


Python 字符串 转换 整数 浮点数 数字

标签:style   ar   使用   sp   on   as   line   size   python   

原文地址:http://blog.csdn.net/wanglei9876/article/details/41652477

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!