get unique random integer from 0, 1, 2, ..., n-1 the python version of matlab randperm() function 得到0至n-1不重复的随机次序的整数,常在初始化时用到 是把0到n-1这些数随机打乱得到的一个数字序列 类似matlab中的randperm函数,只是matlab是从1到n python 随机矩阵,随机整数矩阵 见:https://github.com/gongchunye/randomperm
我就废话不多说了,直接上代码吧!
第一种
def test1():
l = []
for i in range(1000):
l = l + [i]
第二种(append )
def test2():
l = []
for i in range(1000):
l.append(i)
第三种(列表推导式)
def test3():
l = [i for i in range(1000)]
第四种(list )
def test4():
l = lis