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