教程集 www.jiaochengji.com
教程集 >  Python编程  >  Python入门  >  正文 python如何打乱list

python如何打乱list

发布时间:2021-03-22   编辑:jiaochengji.com
教程集为您提供python如何打乱list等资源,欢迎您收藏本站,我们将为您提供最新的python如何打乱list资源

在java中,打乱list要使用collections.shuffle()方法来实现;python中,要利用random模块中的shuffle()方法来实现。

import random
x = [i for i in range(5)]
print(x)
random.shuffle(x)
print(x)

python学习网,大量的免费python视频教程,欢迎在线学习!

您可能感兴趣的文章:
python如何打乱list
python如何将json转成字符串
如何查看python下载的库
如何解决mac python3 中文乱码
mac如何安装python包
Python如何读取excel中的图片
python中如何判断字典中是否有某个值
python如何解决报表显示中文乱码
如何查看python安装了哪些包
python如何自动加空格

[关闭]
~ ~