本文介绍了如何将uint8转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
play.golang/p/BoZkHC8_uA
我想将uint8转换为字符串,但不知道怎么做.
I want to convert uint8 to string but can't figure out how.
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]
This gives me 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])))更多推荐
如何将uint8转换为字符串
发布评论