# 将循环条件改为while True 可取消传参max,无限循环生成下一行 def yhTriangle(max): n = 0 list_next = [1] while n < max: yield list_next list, list_next = list_next, [1] for i in range(len(list)-1): list_next.append(list[i] + list[i+1]) list_next.append(1) n += 1 for i in yhTriangle(6): print(i)你们是怎么把代码贴上去的呀?我感觉我贴了半天都很奇怪