【发布时间】:2015-02-28 13:33:55
【问题描述】:
print("The cost of paint based on whole gallons is: $", round(paint_costs,2))
The cost of paint based on whole gallons is: $ XXX.XX
如何省略 $ 和金额之间的空格,使其显示为:
The cost of paint based on whole gallons is: $XXX.XX
是import.locale吗?
【问题讨论】:
-
在您的情况下,使用字符串格式是正确的答案:
"The cost of paint based on whole gallons is: ${0:.2f}".format(paint_costs)。不要使用round来格式化数字。 -
如果您认为解决方案已经解决了您的问题,请将其标记为已接受。见meta.stackexchange.com/questions/5234/…