當前位置:首頁 » 編程語言 » python全排列組合

python全排列組合

發布時間: 2024-01-08 05:57:04

⑴ 如何用Python列出N個數字的所有排列組合

>> 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)]

熱點內容
php數組位置 發布:2025-09-19 06:06:45 瀏覽:864
伺服器光口配ip 發布:2025-09-19 05:48:37 瀏覽:845
phpmongodb擴展 發布:2025-09-19 05:35:23 瀏覽:776
停資料庫監聽 發布:2025-09-19 05:35:14 瀏覽:45
裸車後需要什麼配置 發布:2025-09-19 05:34:38 瀏覽:186
軟體資源碼 發布:2025-09-19 05:33:58 瀏覽:44
c語言中文編譯器怎麼安裝 發布:2025-09-19 05:33:57 瀏覽:15
啟辰t90的配置怎麼樣 發布:2025-09-19 04:58:54 瀏覽:491
水密碼洗面奶在哪裡買 發布:2025-09-19 04:58:45 瀏覽:98
拒絕訪問本緩存伺服器管理員 發布:2025-09-19 04:53:21 瀏覽:918