##带索引的遍历 for index, value in enumerate(range(10, 100)): print(index, value) ##好用的zip方法 for x, y in zip(range(1, 10), range(10, 20)): print(x, y) ##循环中的的else子句 from math import sqrt for item in range(99, 1, -1): print(item) root = sqrt(item) print(root) if(root == int(root)): print(item) break else: print("没有执行break语句。") ##闭包 def func(x): def inner_func(y): print(x+y) return inner_func f = func(10) f(1) f(2)