Python编程基础知识字符串格式化

1. 简单字符串格式化

format = "Hello, how are you doing %s %s!"
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

Result:

PI with seven decimals: 3.1415927

技术改变世界
原文地址:https://www.cnblogs.com/davidgu/p/2406353.html