package main import ( "fmt" "math/rand" "strconv" "time" ) func main() { //设置随机数种子 rand.Seed(time.Now().UnixNano()) var captcha string for i := 0; i < 6; i++ { //产生0到9的整数 num = rand.Intn(10) //将整数转为字符串 captcha += strconv.Itoa(num) } fmt.Println(captcha) }