关于作者

Discuss / Python / 还是先写好函数再改成生成器好一些

还是先写好函数再改成生成器好一些

Topic source

陪树巨巨度过漫长岁月

#1 Created at ...

def triangles(): L1=[1] while 1: yield L1 L=L1 a = 0 while a<len(L): if a==0:L1=[1] else:L1.append(L[a-1]+L[a]) a=a+1 L1.append(1) x = 0 for t in triangles(): print(t) x= x + 1 if x == 10: break


  • 1

Reply

WARNING: You are using an old browser that does not support HTML5. Please choose a modern browser (Chrome / Microsoft Edge / Firefox / Sarafi) to get a good experience.