python打印九九乘法表的菱形实现
1 NUM = 9 2 for i in range(1, NUM+1): 3 print() 4 for j in range(1, i+1): 5 if j == 1: 6 print(5*(NUM-i)*(" "), end="") 7 print("{0} * {1} = {2} ".format(j, i, i*j), end="") 8 9 for i in range(NUM-1, 0, -1): 10 print() 11 for j in range(1, i+1): 12 if j == 1: 13 print(5*(NUM-i)*(" "), end="") 14 print("{0} * {1} = {2} ".format(j, i, i*j), end="") 15 16