02 2014 档案
摘要:1.combinations(iterable,r) 创建一个迭代器,返回iterable中所有长度为r的子序列,返回的子序列中的项按输入iterable中的顺序排序:官方文档def combinations(iterable, r): # combinations('ABCD', 2) --> AB AC AD BC BD CD # combinations(range(4), 3) --> 012 013 023 123 pool = tuple(iterable) n = len(pool) if r > n: return indice...
阅读全文
摘要:def f(n): while True: tmp = divmod(n, 2) if tmp[1]!=0: return False if tmp[0]==1: return True n = tmp[0]
阅读全文
摘要:引自 python官方文档http://docs.python.org/2/library/functions.html range(stop) range(start,stop[,step])This is a versatile function to create lists containing arithmetic progressions. It is most often used inforloops. The arguments must be plain integers. If thestepargument is omitted, it defaults to1. ..
阅读全文

浙公网安备 33010602011771号