def yhsj(max):
n=0
row = [1]
while (n<max):
n+=1
yield(row)
row = [1] + [row[k] + row[k + 1] for k in range(len(row) - 1)] + [1]
y=yhsj(3)
for i in y:
print(i)
使用python生成器的方法
def yhsj(max):
n=0
row = [1]
while (n<max):
n+=1
yield(row)
row = [1] + [row[k] + row[k + 1] for k in range(len(row) - 1)] + [1]
y=yhsj(3)
for i in y:
print(i)
使用python生成器的方法