关于python占位符数字补0
作者:互联网
%格式化
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
标签:02d,数字,python,占位,2d,2f,radius,print,2.5 来源: https://www.cnblogs.com/umsung/p/15218383.html