2019-04-18
阅读量:
499
Python中的排列
排列
首先导入itertools包以在python中实现permutations方法。此方法将列表作为输入,并返回包含列表形式中所有排列的元组的对象列表。
# A Python program to print all
# permutations using library function
from itertools import permutations
# Get all permutations of [1, 2, 3]
perm = permutations([1, 2, 3])
# Print the obtained permutations
for i in list(perm):
print i
输出
(1,2,3)
(1,3,2)
(2,1,3)
(2,3,1)
(3,1,2)
(3,2,1)
0.0000
0
1
关注作者
收藏
评论(0)
发表评论
暂无数据
推荐帖子
0条评论
0条评论
0条评论

