Python——数字排列组合
生活随笔
收集整理的這篇文章主要介紹了
Python——数字排列组合
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Python——數字排列組合
- 題目
- 代碼
題目
輸出給定數字的排列組合
代碼
不考慮順序combinations:
# 不考慮順序 import itertools myList = list(itertools.combinations([1,2,3,4],3)) print("共有%d個數字符合條件:" %len(myList),myList)考慮順序permutations:
# 考慮順序 import itertools myList = list(itertools.permutations([1,2,3,4],3)) print("共有%d個數字符合條件:" %len(myList),myList)總結
以上是生活随笔為你收集整理的Python——数字排列组合的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 教你用认知和人性来做最棒的程序员
- 下一篇: websocket python爬虫_p