這篇文章主要介紹“golang verb的作用是什么”,在日常操作中,相信很多人在golang verb的作用是什么問(wèn)題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”golang verb的作用是什么”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!
在崇仁等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、外貿(mào)網(wǎng)站建設(shè) 網(wǎng)站設(shè)計(jì)制作按需定制,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站建設(shè),營(yíng)銷型網(wǎng)站,成都外貿(mào)網(wǎng)站建設(shè)公司,崇仁網(wǎng)站建設(shè)費(fèi)用合理。
Printf、Sprintf、Fprintf三個(gè)函數(shù)的format參數(shù)中,均可放置占位符verb,來(lái)對(duì)對(duì)應(yīng)數(shù)值進(jìn)行格式化字符串。
通用verb
%v 值的默認(rèn)格式表示 %+v 類似%v,但輸出結(jié)構(gòu)體時(shí)會(huì)添加字段名 %#v 值的Go語(yǔ)法表示 %T 值的類型的Go語(yǔ)法表示 %% 百分號(hào)
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)存地址,表示為十六進(jìn)制,并加上前導(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)存地址,表示為十六進(jìn)制,并加上前導(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é)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!
本文名稱:golangverb的作用是什么
網(wǎng)站URL:http://www.chinadenli.net/article2/jigcoc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、做網(wǎng)站、全網(wǎng)營(yíng)銷推廣、靜態(tài)網(wǎng)站、虛擬主機(jī)、用戶體驗(yàn)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)