熱線電話:13121318867

登錄
首頁精彩閱讀Python實現的排列組合計算操作示例
Python實現的排列組合計算操作示例
2018-04-02
收藏

Python實現的排列組合計算操作示例

本文實例講述了Python實現的排列組合計算操作。分享給大家供大家參考,具體如下:

1. 調用 scipy 計算排列組合的具體數值

>> from scipy.special import comb, perm
>> perm(3, 2)
6.0
>> comb(3, 2)
3.0
2. 調用 itertools 獲取排列組合的全部情況數    
>> 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)]

數據分析咨詢請掃描二維碼

若不方便掃碼,搜微信號:CDAshujufenxi

數據分析師資訊
更多

OK
客服在線
立即咨詢
日韩人妻系列无码专区视频,先锋高清无码,无码免费视欧非,国精产品一区一区三区无码
客服在線
立即咨詢