Python格式化输出指定宽度及占位符

1 '{:08}'.format(11)
2 
3 
4 
5 mat = "{:020}\t{:028}\t{:032}"
6 print(mat.format(1,2, 3))

冒号后面指定输出宽度,:后的0表示用0占位。

out:

1 '00000011'
2 
3 
4 Name:Aviad      Age:00000025 Height:00001.83

猜你喜欢

转载自www.cnblogs.com/jiangkejie/p/13192602.html