运行 ❯
获取您自己的
Python 服务器
×
更改方向
更改主题,深色/浅色
前往空间
#Use "f" to convert a number into a fixed point number, default with 6 decimals, but use a period followed by a number to specify the number of decimals: txt = "The price is {:.2f} dollars." print(txt.format(45)) #without the ".2" inside the placeholder, this number will be displayed like this: txt = "The price is {:f} dollars." print(txt.format(45))
价格是 45.00 美元。
价格是 45.000000 美元。