第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

寫入文件 int 轉(zhuǎn)換為字符串

寫入文件 int 轉(zhuǎn)換為字符串

Go
胡說叔叔 2022-01-17 10:44:20
我只想簡單地寫入文件從 int 轉(zhuǎn)換的字符串。但是 f.WriteString 而不是 number 從 ASCII 碼表中寫入符號。我預(yù)計“noReport = 12320 nr3h = 105 nr2h = 162 nr1h = 38 ok = 16899”但是卻得到了“noReport = ? nr3h = i nr2h = ¢ nr1h = & ok = ?”
查看完整描述

2 回答

?
慕萊塢森

TA貢獻(xiàn)1810條經(jīng)驗 獲得超4個贊

要使用您的整數(shù)獲取字符串,我建議使用 fmt.Sprintf

會是這樣的;

s := fmt.Sprintf("noReport = %d nr3h = %d nr2h = %d nr1h = %d ok = 16899", 12320, 162, 38)

這會將值分配"noReport = 12320 nr3h = 105 nr2h = 162 nr1h = 38 ok = 16899"s.


查看完整回答
反對 回復(fù) 2022-01-17
?
慕無忌1623718

TA貢獻(xiàn)1744條經(jīng)驗 獲得超4個贊

https://play.golang.org/p/QAXJ4aJBy3


fmt.Printf("os.StdOut is %T\n", os.Stdout)

os.Stdout.WriteString("noReport = 12320 nr3h = 105 nr2h = 162 nr1h = 38 ok = 16899 \n")

os.Stdout.WriteString("12320")


//Output

//os.StdOut is *os.File

//noReport = 12320 nr3h = 105 nr2h = 162 nr1h = 38 ok = 16899 

//12320

對我來說很好。


請給我們您的代碼。


UDP


string(noReport), noReport 是整數(shù)嗎?那是預(yù)期的行為。


使用strconv.Itoa(無報告)。


noReport := 12320

nr3h := 105

nr2h := 162

nr1h := 38

ok := 16899

os.Stdout.WriteString("noReport = "+ strconv.Itoa(noReport) + " nr3h = " + strconv.Itoa(nr3h)+ " nr2h = "+ strconv.Itoa(nr2h)+ " nr1h = "+ strconv.Itoa(nr1h) + " ok = "+ strconv.Itoa(ok)+ "\n") 

或 evanmcdonnal 的回答。


查看完整回答
反對 回復(fù) 2022-01-17
  • 2 回答
  • 0 關(guān)注
  • 157 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號