python 写 组合两两组合
紧挨着 组合 a b c d ----> ab ,bc ,cd
portList = ['a', 'b', 'c', 'd'] for i, p in enumerate(portList): if i == len(portList) - 1: break # p, portList[i + 1] print p print portList[i + 1] print "------"
第一个 ,分别 与 后面的组合 a b c d ----> ab,ac,ad
for i in range(0, len(portList)): for u in range(1, len(portList)): reList.append({ 'a': portList[i]['PORT_CODE'].encode('utf-8'), 'b': portList[u]['PORT_CODE'].encode('utf-8') }) break