数字位数不足补零

aa = '123'

1.format

bb = '{:0>8}'.format(aa)
bb = format(aa, '0>8')
 

2.zfill

cc = zfill(aa, 8)

3.rjust

dd = aa.rjust(8,'0')
 
posted @ 2017-11-21 15:35  hyu9999  Views(72)  Comments(0)    收藏  举报