新聞中心
這篇文章主要介紹“golang verb的作用是什么”,在日常操作中,相信很多人在golang verb的作用是什么問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”golang verb的作用是什么”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
在崇仁等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站制作、網(wǎng)站設(shè)計、外貿(mào)網(wǎng)站建設(shè) 網(wǎng)站設(shè)計制作按需定制,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站建設(shè),營銷型網(wǎng)站,成都外貿(mào)網(wǎng)站建設(shè)公司,崇仁網(wǎng)站建設(shè)費用合理。
Printf、Sprintf、Fprintf三個函數(shù)的format參數(shù)中,均可放置占位符verb,來對對應(yīng)數(shù)值進行格式化字符串。
通用verb
%v 值的默認格式表示 %+v 類似%v,但輸出結(jié)構(gòu)體時會添加字段名 %#v 值的Go語法表示 %T 值的類型的Go語法表示 %% 百分號
package main import "fmt" type Foo struct { Fo int Bar string } func main() { foo := Foo{} fmt.Printf("%v \n", foo) fmt.Printf("%+v \n", foo) fmt.Printf("%#v \n", foo) fmt.Printf("%T \n", foo) fmt.Printf("%% \n") }
輸出:
{0 }
{Fo:0 Bar:}
main.Foo{Fo:0, Bar:""}
main.Foo
%
Chan、Func、Map、Ptr、Slice、UnsafePointer
%p 內(nèi)存地址,表示為十六進制,并加上前導(dǎo)的0x
package main import "fmt" type Foo struct { bar int } func main() { s := []string{} fmt.Printf("%p \n", s) m := map[string]string{} fmt.Printf("%p \n", m) c := make(chan int) fmt.Printf("%p \n", c) f := func() {} fmt.Printf("%p \n", f) i := 1 p := &i fmt.Printf("%p \n", &i) fmt.Printf("%p \n", p) foo := Foo{} fmt.Printf("%p \n", foo) }
0x1195ab8
0xc000070180
0xc00006e060
0x109b260
0xc000016078
0xc000016078
%!p(main.Foo={0})
fmtBool
%t 內(nèi)存地址,表示為十六進制,并加上前導(dǎo)的0x
package main import "fmt" func main() { t := true fmt.Printf("%t \n", t) f := false fmt.Printf("%t \n", f) }
true
false
fmtFloat
b g G x X f F e E
fmtComplex
fmtInteger
fmtString
fmtBytes
到此,關(guān)于“golang verb的作用是什么”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
新聞標題:golangverb的作用是什么
鏈接分享:http://www.dlmjj.cn/article/jigcoc.html