python 一条语句生成九九乘法表并格式化
print('\n'.join(['\t'.join(["%s *%2s =%+3s" % (j, i, i * j) if j != 1 else "%s *%2s =%+2s" % (j, i, i * j) for j in range(1, i + 1)]) for i in range(1, 10)]))
# 打印 99 乘法表 print('\n'.join(['\t'.join(["%s *%2s =%+3s" % (j, i, i * j) if j != 1 else "%s *%2s =%+2s" % (j, i, i * j) for j in range(1, i + 1)]) for i in range(1, 10)]))
效果