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
吗?
答案 0 :(得分:1)
在打印功能中添加sep=""
参数。
print("The cost of paint based on whole gallons is: $", round(paint_costs,2), sep="")
答案 1 :(得分:1)
使用Py3功能sep
print("The cost of paint based on whole gallons is: $", round(paint_costs,2),sep = "")
其他方式包括
print("The cost of paint based on whole gallons is: ${}".format(round(paint_costs,2)))
print("The cost of paint based on whole gallons is: $%s"%(round(paint_costs,2)))