无法在Python中随机播放列表 [英] Cannot shuffle list in Python
本文介绍了无法在Python中随机播放列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的清单:
biglist = [ {'title':'U2','link':'u2.com'}, {'title':'beatles','link':'beatles.com'} ]
print random.shuffle(biglist)
那是行不通的!不返回任何内容.
that doesn't work! It returns none.
推荐答案
random.shuffle
随机排列列表,它不返回新列表.因此,请检查biglist
,而不是random.shuffle
的结果.
random.shuffle
shuffles the list, it does not return a new list. So check biglist
, not the result of random.shuffle
.
random
模块的文档: http://docs.python.org/library/random.html
这篇关于无法在Python中随机播放列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文