占位符
var a = 100
fmt.Printf("%T\n",n) //查看变量类型
//int
fmt.Printf("%v\n") //查看变量的值
//100
fmt.Printf("%d\n",n) //查看十进制
//100
fmt.Printf("%b\n",n) //查看二进制
//1100100
fmt.Printf("%o\n",n) //查看八进制
//144
fmt.Printf("%x\n",n) //查看十六进制
//64
fmt.Printf("%c",a);输出单个字符。
s := "Hello"
fmt.Printf("%s\n",s) //查看字符串
//Hello
fmt.Printf("%v\n",s)
//Hello
fmt.Printf("%#v\n",s) //打印字符串时带双引号
// "Hello"
网友评论