問題:
I have a function taking float arguments (generally integers or decimals with one significant digit), and I need to output the values in a string with two decimal places (5 → 5.00, 5.5 → 5.50, etc).我有一個採用浮點參數的函數(通常是整數或帶一位有效數字的小數),我需要在一個帶有兩個小數位(5 → 5.00、5.5 → 5.50 等)的字符串中輸出值。 How can I do this in Python?我怎樣才能在 Python 中做到這一點?
解決方案:
參考一: https://en.stackoom.com/question/PndW參考二: https://stackoom.com/question/PndW