def yhTriangle(max):
N = [1]
i = 0
while i < max:
yield N
N.append(0)
N = [N[i - 1] + N[i] for i in range(len(N))]
i = i + 1
for n in yhTriangle(10):
print(n)
generator生成器,在yield的地方停下来
def yhTriangle(max):
N = [1]
i = 0
while i < max:
yield N
N.append(0)
N = [N[i - 1] + N[i] for i in range(len(N))]
i = i + 1
for n in yhTriangle(10):
print(n)
generator生成器,在yield的地方停下来