杨辉三角python的最佳实现方式,牛的不能再牛了

def triangles():
N = [1]
while True:
yield N
N.append(0)
N = [N[i-1] + N[i] for i in range(len(N))]

n = 0
for t in triangles():
print(t)
n = n + 1
if n == 10:
break

廖雪峰老师出的题

原文地址:https://www.cnblogs.com/xiangpiaopiao2011/p/9300792.html