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'