开发者

Cannot shuffle list in Python

开发者 https://www.devze.com 2022-12-08 01:42 出处:网络
This is my list: biglist = [ {\'title\':\'U2\',\'link\':\'u2.com\'}, {\'title\':\'beatles\',\'l开发者_StackOverflow社区ink\':\'beatles.com\'} ]

This is my list:

biglist = [ {'title':'U2','link':'u2.com'}, {'title':'beatles','l开发者_StackOverflow社区ink':'beatles.com'} ]
print random.shuffle(biglist)

that doesn't work! It returns none.


random.shuffle shuffles the list, it does not return a new list. So check biglist, not the result of random.shuffle.

Documentation for the random module: http://docs.python.org/library/random.html

0

精彩评论

暂无评论...
验证码 换一张
取 消