golang 字符串與int類型轉換

一、字符串轉int
func Atoi(s string) (int, error)

案例:
golang 字符串與int類型轉換
執行結果:
sf@SFdeMacBook-Pro  ~/Documents/project/src/test  go build int_string.go
sf@SFdeMacBook-Pro  ~/Documents/project/src/test  ./int_string
int, 100

二、int轉字符串
func Itoa(i int) string

golang 字符串與int類型轉換

執行結果:
sf@SFdeMacBook-Pro  ~/Documents/project/src/test  go build int_string.go
sf@SFdeMacBook-Pro  ~/Documents/project/src/test  ./int_string
string,100

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章