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... 阅读全文
posted @ 2014-02-19 16:51 天外飞仙丶 阅读(11736) 评论(0) 推荐(0)
摘要:def f(n): while True: tmp = divmod(n, 2) if tmp[1]!=0: return False if tmp[0]==1: return True n = tmp[0] 阅读全文
posted @ 2014-02-18 16:44 天外飞仙丶 阅读(1253) 评论(0) 推荐(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. .. 阅读全文
posted @ 2014-02-10 14:39 天外飞仙丶 阅读(729) 评论(0) 推荐(0)