特牛网址导航

go语言byte类型报错cannot use "c" (type string) as type byte in assignment-CSDN博客

网友收藏
文章浏览阅读1w次。  练习Go修改字符串的时候遇到这个问题:cannot use "c" (type string) as type byte in assignment,代码如下:package mainimport "fmt"func main() { s := "hello" c := []byte(s) // 将字符串转为[]byte类型 c[0] = 'c' ..._cannot use value.(string) (comma, ok expression of type string) as []byte va