Python生成九九乘法表到Excel

 1 import xlwt
 2 
 3 wbk=xlwt.Workbook()
 4 sheet1=wbk.add_sheet("my_sheet1")
 5 
 6 for i in range(1,10):
 7     for j in range(1,i+1):
 8         sheet1.write(i-1,j-1,"%sx%s=%s"%(j,i,j*i))
 9 
10 wbk.save("C:/test.xls")
11 print "Done!"
12 
13 '''
14 for i in range(1,10):
15     for j in range(0,2*i,2):
16         sheet1.write(i-1,j,"%s * %s = "%(j/2+1,i))
17         sheet1.write(i-1,j+1,'%s'%((j/2+1)*i))
18 '''

转载于:https://www.cnblogs.com/c-hy/archive/2012/08/25/2656674.html

你可能感兴趣的:(Python生成九九乘法表到Excel)