oo

with open('乘法口诀表.txt','w') as f:
    f.writelines("1\t2\t3\t4\t5\t6\t7\t8\t9\n")
    f.writelines("-"*70+'\n')
    str_list=[]
    for x in range(1,10):
        for y in range(1,10):
            str_list.append('%d'%(x*y))
            str_list.append('\t')
            str_string="".join(str_list)
            str_string=str_string+'\n'
        f.writelines(str_string)
        str_list=[]

你可能感兴趣的:(Python学习)