代码示例:(标识:python_string_formatting_2)
python_string_formatting_2.py
price = 52
txt = "The price is {:.2f} dollars"
print(txt.format(price))
运行结果: