def triangles():
last=[1]
while True:
yield last
next=[last[n-1]+last[n] for n in range(1,len(last))] #先构建中间的元素
next=[1]+next+[1] #首尾+1
last=next
认真学习了,受益非浅
Sign in to make a reply
Kris-As-A-Service
def triangles():
last=[1]
while True:
yield last
next=[last[n-1]+last[n] for n in range(1,len(last))] #先构建中间的元素
next=[1]+next+[1] #首尾+1
last=next