import randomaList=[1,2,3,4,5,6,7]random.shuffle(aList,random=None)
def shuffle(self,x,random=None): if random is None: randbelow = self._randbelow for i in reversed(range(1,len(x))): # pick an element in x[:i+1] with which to exchange x[i] j = randbelow(i+1) x[i],x[j] = x[j],x[i] else: _int = int for i in reversed(range(1,len(x))): # pick an element in x[:i+1] with which to exchange x[i] j = _int(random() * (i+1)) x[i],x[j] = x[j],x[i]shuffle源码
源码没有返回值,打乱的是原列表,所以不能print (random.shuffle(aList,random=None))
总结以上是内存溢出为你收集整理的shuff打乱排序全部内容,希望文章能够帮你解决shuff打乱排序所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)