【Python】不足N位左补零
代码:
#encoding=utf-8 arr=[1,2,45,543,43,5435,454,3,0] for i in arr: print("{:0>4d}".format(i))
输出:
C:\hy\py>python 06-leftZero.py
0001
0002
0045
0543
0043
5435
0454
0003
0000
END
代码:
#encoding=utf-8 arr=[1,2,45,543,43,5435,454,3,0] for i in arr: print("{:0>4d}".format(i))
输出:
C:\hy\py>python 06-leftZero.py
0001
0002
0045
0543
0043
5435
0454
0003
0000
END