將浮點數限制爲兩位小數 - Limiting floats to two decimal points

問題:

I want a to be rounded to 13.95 . 我但願將a舍入爲13.95 html

>>> a
13.949999999999999
>>> round(a, 2)
13.949999999999999

The round function does not work the way I expected. round功能不能按我預期的方式工做。 python


解決方案:

參考一: https://stackoom.com/question/1uWa/將浮點數限制爲兩位小數
參考二: https://oldbug.net/q/1uWa/Limiting-floats-to-two-decimal-points
相關文章
相關標籤/搜索