首页 > 编程语言 > 详细

python 数字和字符串转换问题

时间:2015-01-19 18:49:44      阅读:157      评论:0      收藏:0      [点我收藏+]

一、python中字符串转换成数字

(1)import string 

tt=‘555‘

ts=string.atoi(tt)

ts即为tt转换成的数字

转换为浮点数 string.atof(tt)

(2)直接int

int(tt)即可。

二、数字转换成字符串

tt=322

tem=‘%d‘ %tt

tem即为tt转换成的字符串

python 数字和字符串转换问题

原文:http://www.cnblogs.com/zmlctt/p/4234257.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!