python 2.6 引入了itertools模塊,使得排列組合的實現(xiàn)非常簡單: 復(fù)制代碼代碼如下: import itertools 有序排列:e.g., 4個數(shù)內(nèi)選2個排列: 復(fù)制代碼代碼如下: >>> print list(itertools.permutations([1,2,3,4],2)) [ (1, 2), (1, 3), (1, 4), (2, 1), (2, 3), ...
www.dbjr.com.cn/article/349...htm 2025-5-31