代码示例:(标识:python_string_format_3)
python_string_format_3.py
quantity = 5
itemno = 789
price = 24.36
myorder = "I want to pay {2} dollars for {0} pieces of item {1}."
print(myorder.format(quantity, itemno, price))
运行结果: