您现在的位置是:课程教程文章
Python怎么把字符串变成数字格式
2023-12-18 19:25课程教程文章 人已围观
Python怎么把字符串变成数字格式
方法一:
类中进行导入string
import string str='555' num=string.atoi(str)
num即为str转换成的数字
转换为浮点数:
string.atof(str)
方法二:
直接使用int
int(str)
补充:数字转换成字符串
num=322 str='%d'%num
str即为num转换成的字符串
更多技术请关注Python视频教程。
课程教程:Python怎么把字符串变成数字格式上一篇:Python在命令行如何切换目录
下一篇:没有了