b=[] for i in range(0,9): c=[] for j in range(0,i): if j==0: c.append(b[i-1][j]) if j<=i-2:#执行完第一个if,接着执行第二个if c.append(b[i-1][j]+b[i-1][j+1]) c.append(1)#每次循环结束b列表尾部添加1 b.append(c) # print(b) for i in b: for k in i: print(k,end=" ") print()
原文地址:https://www.cnblogs.com/Python-T/p/9426944.html
时间: 2024-10-09 16:40:30