1.字符串格式化运算符% print “%3d %0.2f” % (year,principal)
2.format()函数单独格式化 print format(year,"3d"),format(principal,"0.2f")
3.字符串的format()方法 print "{0:3d} {1:0.2f}".format(year,principal)
1.字符串格式化运算符% print “%3d %0.2f” % (year,principal)
2.format()函数单独格式化 print format(year,"3d"),format(principal,"0.2f")
3.字符串的format()方法 print "{0:3d} {1:0.2f}".format(year,principal)