#右对齐打印九九乘法表

与正常打印的区别在于右对齐要正行打印后再右对齐

方法:

for i in range(1,10):                                                            #取横的乘数
    s = ''                                                                                #每次打印完一行后,给s初始化为空
    for j in range(i,10):                                                           #取竖列的乘数
        s += '{}*{}={:<{}}'.format(i,j,i*j,3 if j < 4 else 4)             #拼接完整一行,并对每一个乘法空格其进行格式化
    print('{:>72}'.format(s))                                                    #打印乘法表的每一行,并进行格式换右对齐


图片.png