package main
import (
"fmt"
"strconv"
)
func main() {
i := make([]byte, 200)
i[0] = '1'
i[1] = '2'
i[2] = '3'
i[3] = '4'
var str = string(i)
fmt.Print(str, "\n") //1234
va, _ := strconv.Atoi(str)
fmt.Print(va) //0
为什么是 0
}
有疑问加站长微信联系(非本文作者)
package main
import (
"fmt"
"strconv"
)
func main() {
i := make([]byte, 200)
i[0] = '1'
i[1] = '2'
i[2] = '3'
i[3] = '4'
var str = string(i)
fmt.Print(str, "\n") //1234
va, _ := strconv.Atoi(str)
fmt.Print(va) //0
为什么是 0
}
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
`单行代码`
package main
import (
"fmt"
"strconv"
)
func main() {
i := make([]byte, 200)
i[0] = '1'
i[1] = '2'
i[2] = '3'
i[3] = '4'
var str = string(i)
fmt.Print(str, "\n") //1234
va, _ := strconv.Atoi(str)
fmt.Print(va) //0
为什么是 0
}