package main

import (
    "fmt"
)

func main() {
    a := 1
    fmt.Println(a)
    //前置补0
    fmt.Printf("%03d", a)
    fmt.Println("")
    fmt.Printf("%0*d", 3, a)
}
[ `run` | done: 1.581527ms ]
  1
  001
  001

 

posted on 2014-04-15 13:58  forrestsun  阅读(16698)  评论(0编辑  收藏  举报