python 数字和字符串转换问题

来源:互联网 发布:小说地图制作软件 编辑:程序博客网 时间:2024/05/19 14:39

一、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转换成的字符串

题目链接:点击打开链接

原创粉丝点击