1. 简单字符串格式化
format = "Hello, how are you doing %s %s!"
values = ("David", "Gu")
print format % values
values = ("David", "Gu")
print format % values
Result:
Hello, how are you doing David Gu!
format = "PI with seven decimals: %.7f"
from math import pi
print format % pi
from math import pi
print format % pi
Result:
PI with seven decimals: 3.1415927