1.格式化输出字符串
print("My name is %s" % ("OLIVER"))
2.格式化输出整数
print("The number is %d" % (100))
3.格式化输出小数
print("The number is %f" % (37.12))
3.1格式化输出小数(保留位数)
print("The number is %.1f" % (37.19))
4.指定占位符宽度
print("String:%10s Int:%6d Float:%9.3f" % (‘QIN‘,23,78.23415))
4.1指定占位符宽度(左对齐)
print("String:%-10s Int:%-6d Float:%-9.3f" % (‘QIN‘,23,78.23415))
4.2指定占位符
print("String:%-10s Int:%06d Float:%-9.3f" % (‘QIN‘,23,78.23415))
5.科学计数法
format(0.0000000001,‘.2e‘)
原文:http://www.cnblogs.com/OliverQin/p/6074174.html