效果图:
v
代码:
#定义一个函数:
def triangles():
...: L = [1]
...: while(True):
...: yield L
...: M = [L[x] + L[x + 1] for x in range(len(L) - 1)]
...: L = [1] + M + [1]
#在命令行输入:则会生成一个生成器,可以通过next()查看;
triangles()