def rectangle(m): n, b = 0, [1] while n < m: yield b b = [1] + [b[i] + b[i + 1] for i in range(len(b) - 1)] + [1] n += 1 for x in rectangle(10): print(x)
结果是这样的.
def rectangle(m): n, b = 0, [1] while n < m: yield b b = [1] + [b[i] + b[i + 1] for i in range(len(b) - 1)] + [1] n += 1 for x in rectangle(10): print(x)
结果是这样的.
转载于:https://www.cnblogs.com/fangjianbin/p/4964215.html