几个有用的python函数 (笛卡尔积, 排列, 组合)
kitt
posted @ 2014年1月22日 01:10
in 技术类 Tech
, 18552 阅读
product 笛卡尔积
permutations 排列
combinations 组合,没有重复
combinations_with_replacement 组合,有重复
详见官网文档
>>> import itertools >>> for i in itertools.product('ABCD', repeat = 2): ... print i, ... ('A', 'A') ('A', 'B') ('A', 'C') ('A', 'D') ('B', 'A') ('B', 'B') ('B', 'C') ('B', 'D') ('C', 'A') ('C', 'B') ('C', 'C') ('C', 'D') ('D', 'A') ('D', 'B') ('D', 'C') ('D', 'D') >>> for i in itertools.permutations('ABCD', 2): ... print i, ... ('A', 'B') ('A', 'C') ('A', 'D') ('B', 'A') ('B', 'C') ('B', 'D') ('C', 'A') ('C', 'B') ('C', 'D') ('D', 'A') ('D', 'B') ('D', 'C') >>> for i in itertools.combinations('ABCD', 2): ... print i, ... ('A', 'B') ('A', 'C') ('A', 'D') ('B', 'C') ('B', 'D') ('C', 'D') >>> for i in itertools.combinations_with_replacement('ABCD', 2): ... print i, ... ('A', 'A') ('A', 'B') ('A', 'C') ('A', 'D') ('B', 'B') ('B', 'C') ('B', 'D') ('C', 'C') ('C', 'D') ('D', 'D')
2020年2月22日 03:29
Since the name signifies, deep cleansing represents another degree of cleaning upward your office or home. Basic cleansing includes general cleanup like wiping as well as vacuuming your kitchen, bathroom, bedroom and family room floors, in addition to cleaning the actual cupboard doorways, tables, seats, and the like, using drinking water or every other basic cleansing products; nevertheless, deep cleaning is all about watching the particulars and eliminating hidden dirt, dirt, as well as small unsightly stains. It is really a top in order to bottom scrubbing of your house, from ceilings in order to floors, Types of deep cleansing include cleansing what’s between your tiles, behind the washer, under the actual sink, within the oven, cleaning the area corners…etc.
2020年2月22日 23:17
Earphones thing it is advisable to check relating to before engaging a upholstery cleaning company is normally they version of carpet housecleaning equipment and additionally methods make use considering the fact that they focus of any only one type about service. You will also ask assuming they are familiar with your specific version of rugs and additionally carpets considering the fact that they will use the right method to cleaning for genital herpes virus treatments have. Earphones thing you're looking for is for use on your Oriental floor covering or Local carpets that should be ruined website company used harmful carpet housecleaning process or possibly chemicals.