def infinite_sevens(): while True: yield 7 for i in infinite_sevens(): print(i)
结果:
>>> 7 7 7 7 7 7 7 ...
0