📜  数组的随机有序切片 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:37.399000             🧑  作者: Mango

代码示例1
import random as rd
import numpy as np

mylist = list(np.linspace(0,50,50))
sliceSize = 3 # +1 below because python start counting frfom zero
result = mylist[rd.randrange(len(mylist)-sliceSize+1):][:sliceSize]
print(result)
Output: [6.122448979591837, 7.142857142857143, 8.16326530612245]