为了账号安全,请及时绑定邮箱和手机立即绑定

将十六进制更改为字符串

将十六进制更改为字符串

Go
MMMHUHU 2021-12-07 18:56:08
我正在阅读 Golang 教程,我在这部分package mainimport (    "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但我仍然有点困惑如何使用它而不是显示十六进制显示字符串
查看完整描述

1 回答

?
人到中年有点甜

TA贡献1895条经验 获得超7个赞

math/rand.Seed是一个函数;您正在打印函数在内存中的位置。您可能打算执行以下操作:


package main


import (

    "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())

}


查看完整回答
反对 回复 2021-12-07
  • 1 回答
  • 0 关注
  • 158 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信