问题:
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