1. a = '6'
    2. # 增加到6位
    3. a = a.zfill(6)
    4. # 此时a为:‘000006’

    上面的代码等效于:

    1. num = number
    2. num = str(num)
    3. n = len(num)
    4. if n < 6:
    5. temp = '0'*(6-n)
    6. num = temp + num