好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Python中排列组合计算操作的实现示例

这篇文章主要介绍了Python实现的排列组合计算操作,涉及Python数学运算的相关函数与使用技巧,需要的朋友可以参考下

>> from scipy.special import comb, perm
>> perm(3, 2)
6.0
>> comb(3, 2)
3.0 
>> from itertools import combinations, permutations
>> permutations([1, 2, 3], 2)
<itertools.permutations at 0x7febfd880fc0>
        # 可迭代对象
>> list(permutations([1, 2, 3], 2))
[(1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)]
>> list(combinations([1, 2, 3], 2))
[(1, 2), (1, 3), (2, 3)] 

以上就是Python中排列组合计算操作的实现示例的详细内容,更多请关注Gxl网其它相关文章!

查看更多关于Python中排列组合计算操作的实现示例的详细内容...

  阅读:45次