import xlwt
workbook = xlwt.Workbook()
sheet1=workbook.add_sheet(‘test’,cell_overwrite_ok=True)
#生成sheet:test,如下图1:
data = {
“1”:[u"张三",150,120,100],
“2”:[“wang”,90,99,95],
“3”:[“wu”,60,66,68]
}
num = [a for a in data]
ldata=[]
num.sort()
for x in num:
t = [int(x)]
for a in data[x]:
t.append(a)
ldata.append(t)
for i,p in enumerate(ldata):
for j,q in enumerate§:
sheet1.write(i,j,q)
workbook.save('H:\\test3.xls')#生成结果,保存到test3.xls中,如图2.
作者:Web魔法师
来源:CSDN
原文:https://blog.csdn.net/lengyuewusheng99/article/details/53508069
版权声明:本文为博主原创文章,转载请附上博文链接!