1. 斐波那契 from itertools import islice def fib(): a, b = 0, 1 while True: yield a a, b = b, a+b print list(islice(fib(), 5)) # [0, 1, 1, 2, 3] 2. for……else……用法(以查找素数为例) 正常版本: def print_prime(n): for i in xrange(2, n): found = True for j in xrange(2, i)…