2
【笔记】Go语言的随机数
source link: https://loli.fj.cn/2023/01/20/Go%E8%AF%AD%E8%A8%80%E7%9A%84%E9%9A%8F%E6%9C%BA%E6%95%B0/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
【笔记】Go语言的随机数
2023-01-20Go语言学习指北
Go语言的随机数学习笔记
生成随机数
- 默认随机数种子为
1970-1-1 0:0:0
package main
import (
"math/rand"
"time"
)
func main() {
// 指定随机数种子
rand.Seed(time.Now().UnixNano())
// 指定生成随机数最大值
rand.Intn(随机数最大值)
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK