关于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
 
上一篇:理论解析:如何让A*寻路算法适应2D网格平台游戏


下一篇:SketchUp Pro 2020 for Mac(草图大师) v20.2.171中文激活版