洗牌随机整数,打印所有可能性

2024-04-20 09:30:52 发布

您现在位置:Python中文网/ 问答频道 /正文

Possible Duplicate:
How to generate all permutations of a list in Python

假设我有一个范围,0-2。我想洗牌这些数字并打印出所有的可能性:

[0, 1, 2]
[0, 2, 1]
[1, 2, 0]
[1, 0, 2]
[2, 0, 1]
[2, 1, 0]

在Python中,如何在0-N范围内执行此操作?在


Tags: oftoin数字all可能性generatelist