%格式化 print('%2d-%02d-%.2f' % (3, 1, 2.113)) 输出 :' 3-01-2.11' format()格式化 print("{0:2d}-{1:02d}-{2:.2f}-{3:0<4d}".format(1, 5, 6, 7)) 输出:' 1-05-6.00-7000' print("{0}{1:0>2d}{2:0>2d}{3:0>2d}".format(*time.localtime())) f-sting() r=2.5 s=3.14*r print(f'The area of a circle with radius {r} is {s:.2f}') 输入:The area of a circle with radius 2.5 is 19.62