2024-04-20 02:30:55 发布
网友
如何将字符串格式化为%或.format(),一个要舍入并显示到10或100位的浮点?你知道吗
%
.format()
比如4552.33到4550到10秒或者4600到100秒?你知道吗
使用内置函数^{}
>>> import math >>> f = 4552.33 >>> int(round(f, -int(math.log10(10)))) 4550 >>> int(round(f, -int(math.log10(100)))) 4600
使用内置函数^{}
相关问题 更多 >
编程相关推荐