Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我想在 Go 中填充一个数字:
4 => "004" 23 => "023"
我该怎么做?
使用fmt 包中的"%0xd"标志 to ,其中是要填充的前导零的数量。fmt.Printfx
"%0xd"
fmt.Printf
x
import "fmt" fmt.Printf("%03d", 4) // will print "004"
界面与 C 中的相同。