以下代碼package mainimport ( "fmt")func main() { fmt.Println(say(9))}func say(num int)(total string){return fmt.Sprintf("There are %s reasons to code!", num)}產生以下輸出There are %!s(int=9) reasons to code!我的問題我應該怎么做才能在字符串中插入一個數字?
3 回答

米脂
TA貢獻1836條經驗 獲得超3個贊
如果您想始終使用任何類型的“默認”表示形式,請使用%v
as in
fmt.Sprintf("There are %v reasons to code!", num)
- 3 回答
- 0 關注
- 274 瀏覽
添加回答
舉報
0/150
提交
取消