def reverse(data):
for i in range(len(data)-1, -1, -1):
yield data[i]
for i in reverse([1, 2, ,3, 4]):
print(i)
4
3
2
1
square = (x**2 for x in range(10))
for i in square:
print(i)
0
1
4
9
sum(x**2 for x in range(10))
285
原文:https://www.cnblogs.com/babysteps/p/python_note_12.html