将十六进制更改为字符串

我正在阅读 Golang 教程,我在这部分


package main


import (

    "fmt"

    "math/rand"

)


func main() {

    fmt.Println("My favorite number is", rand.Seed)

}

这返回 My favorite number is 0xb1c20


我一直在阅读https://golang.org/pkg/math/rand/#Seed但我仍然有点困惑如何使用它而不是显示十六进制显示字符串


MMMHUHU
浏览 160回答 1
1回答

人到中年有点甜

math/rand.Seed是一个函数;您正在打印函数在内存中的位置。您可能打算执行以下操作:package mainimport (    "fmt"    "math/rand")func main() {    rand.Seed(234) // replace with your seed value, or set the seed based off                   // of the current time    fmt.Println("My favorite number is", rand.Int())}
打开App,查看更多内容
随时随地看视频慕课网APP