Python下的杨辉三角
#!/usr/bin/env python3
# -*- coding utf-8 -*-
def triangle():
l = [1]
a = 1
while True:
if a == 1:
yield l
else:
l = [l[i-1] + l[i] for i in range(1,a-1)]
l = [1] + l + [1]
yield l
a = a + 1
n = 0
for t in triangle():
print(t)
n = n + 1
if n == 10:
break
~