for i in range(1,10): for j in range(1,i + 1): print('%s*%s=%s' %(j,i,i*j), end=' ') print() # 由用户指定相乘到多少 n = int(input('number: ')) for i in range(1,n + 1): for j in range(1,i + 1): print('%s*%s=%s' %(j,i,i*j), end=' ') print()
结果输出:
for i in range(1,10): for j in range(1,i + 1): print('%s*%s=%s' %(j,i,i*j), end=' ') print() # 由用户指定相乘到多少 n = int(input('number: ')) for i in range(1,n + 1): for j in range(1,i + 1): print('%s*%s=%s' %(j,i,i*j), end=' ') print()
结果输出: