python一行代码实现9x9乘法表

for i in range(1,10):
    for j in range(1,i+1):
        print('%s * %s =  %s  ' %(i,j,i*j),end="")
    print()

print('\n'.join(['\t'.join(["%2s*%2s=%2s"%(j,i,i*j) for j in range(1,i+1)]) for i in range(1,10)]))

  

posted @ 2018-08-30 21:29  Hear7  阅读(681)  评论(0编辑  收藏  举报