要点
- 显示变量类型:%T
- 码流十六进制串:%x or %X
代码示例
package main
import (
"fmt"
)
/*
The type of data is []uint8
a= 48656c6c6f
b= 48656C6C6F
c= Hello
*/
func main() {
data := []byte{'H', 'e', 'l', 'l', 'o'}
fmt.Printf("The type of data is %T\n", data)
a := fmt.Sprintf("%x", data)
b := fmt.Sprintf("%X", data)
c := string(data)
fmt.Println("a=", a)
fmt.Println("b=", b)
fmt.Println("c=", c)
}
有疑问加站长微信联系(非本文作者)