亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

python 排列組合之itertools

 更新時間:2013年03月20日 20:53:51   作者:  
python 排列組合之itertools,需要的朋友可以參考一下
python 2.6 引入了itertools模塊,使得排列組合的實現(xiàn)非常簡單:
復制代碼 代碼如下:

import itertools 

有序排列:e.g., 4個數(shù)內(nèi)選2個排列:
復制代碼 代碼如下:

>>> print list(itertools.permutations([1,2,3,4],2))
[(1, 2), (1, 3), (1, 4), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (3, 4), (4, 1), (4, 2), (4, 3)]

無序組合:e.g.,4個數(shù)內(nèi)選2個:
復制代碼 代碼如下:

>>> print list(itertools.combinations([1,2,3,4],2))
[(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]

相關(guān)文章

最新評論