http://play.golang.org/p/BoZkHC8_uA
我想将uint8转换为字符串,但不知道如何。
package main import "fmt" import "strconv" func main() { str := "Hello" fmt.Println(str[1]) // 101 fmt.Println(strconv.Itoa(str[1])) }
这给我 prog.go:11: cannot use str[1] (type uint8) as type int in function argument [process exited with non-zero status]
prog.go:11: cannot use str[1] (type uint8) as type int in function argument [process exited with non-zero status]
任何想法?
只需将其转换:
fmt.Println(strconv.Itoa(int(str[1])))