%d : decimal integer
%x %o %b : integer in hexadecimal(十六进制) octal(八进制) binaery(二进制)
%f %g %e:floating-point number: 3.141593 3.141592653589793 3.141593e+00
%t: boolean:true or false
%c: rune(Unicode code point)
%s: string
%q: quoted string "abc" or rune 'c'
%v: any value in a natural format
%T: type of any value
fmt.Printf("%d %d\n", 1, 'c')
fmt.Printf("%x %o %b \n", 31, 31, 31)
fmt.Printf("%f %g %e \n", 3.141592653589793238462643383249901429, 3.141592653589793238462643383249901429, 3.141592653589793238462643383249901429)
fmt.Printf("%t %t \n", true, false)
fmt.Printf("%c %s\n", 'd', "d")
fmt.Printf("%q %q %q \n", "abcd", "c", 'c')
fmt.Printf("%v %v %v\n", symbol1, "abcd", 'c')
fmt.Printf("%T %T %T\n", symbol1, "abcd", 'c')
对应的输出为
1 99
1f 37 11111
3.141593 3.141592653589793 3.141593e+00
true false
d d
"abcd" "c" 'c'
[usd eur ¥] abcd 99
[3]string string int32
有疑问加站长微信联系(非本文作者)