Python中固定小数位数
📁 python, 人工智能
Python中是否有类似于JS中toFixed()的函数?我需要类似这样的功能:
>>> a = 12.3456789>>> a.toFixed(2)'12.35'>>> a.toFixed(0)'12'>>> b = 12.000001>>> b.toFixed(3)'12.000' 📁 python, 人工智能
Python中是否有类似于JS中toFixed()的函数?我需要类似这样的功能:
>>> a = 12.3456789>>> a.toFixed(2)'12.35'>>> a.toFixed(0)'12'>>> b = 12.000001>>> b.toFixed(3)'12.000'