pei*_*ixe 0 python decimal rounding
我一直在python中搜索一个方法,只得到十进制数字逗号右边的4位数,但我找不到.看看这篇文章,---> 使用新的Python格式函数舍入小数 ,但函数写在那里...
>>> n = 4
>>> p = math.pi
>>> '{0:.{1}f}'.format(p, n)
'3.1416'
Run Code Online (Sandbox Code Playgroud)
...似乎不适用于我的情况.
我导入了模块"math"和"decimal",但也许我错过了一些其他导入,但我不知道要导入哪些.
谢谢大家,对不起,如果这个问题已经发布了.
PEIXE
| 归档时间: |
|
| 查看次数: |
559 次 |
| 最近记录: |