s := "some string"
b := []byte(s) // convert string -> []byte
s2 := string(b) // convert []byte -> string
Run Code Online (Sandbox Code Playgroud)
Go string和[]byteGo 之间有什么区别?
何时使用"他"或"她"?
为什么?
bb := []byte{'h','e','l','l','o',127}
ss := string(bb)
fmt.Println(ss)
Run Code Online (Sandbox Code Playgroud)
你好
输出只是"hello",缺乏127,有时我觉得这很奇怪.