# while 循环 r = 1 while r <= 9: c = 1 while c <= r: print('{}*{}={}'.format(c, r, c * r), end=' ') c += 1 r += 1 print() # 默认情况下 end 参数的值为一个换行符
1 # for 循环 2 for r in range(1, 10): 3 for c in range(1, r + 1): 4 print("{}*{}={}".format(c, r, c * r), end=' ') 5 print() # 默认换行