package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
rand.Seed(time.Now().UnixNano())
slice := []int{0, 2, 3, 4, 5, 6, 7, 8}
rm := rand.Intn(len(slice))
slice = append(slice[:rm], slice[rm+1:]...)
fmt.Println(slice)
}
Golang-slice:随机删除切片元素
最新推荐文章于 2023-09-26 05:16:45 发布