python裏如何保存float類型的小數的位數

python保留兩位小數 python保留兩位小數:html In [1]: a = 5.026 In [2]: b = 5.000 In [3]: round(a,2) Out[3]: 5.03 In [4]: round(b,2) Out[4]: 5.0 In [5]: '%.2f' % a Out[5]: '5.03' In [6]: '%.2f' % b Out[6]: '5.0
相關文章
相關標籤/搜索