excel 保存方法:
book = xlwt.Workbook()
#创建表单
sheet = book.add_sheet(u'sheet1',cell_overwrite_ok=True)
sheet.write(0,0,'id')
sheet.write(0,1,'text')
sheet.write(0,2,'user_id')
sheet.write(0,3,'geo_coordinates1')
sheet.write(0,4,'geo_coordinates2')
sheet.write(0,5,'created_at')
i =1
for all in searchRes:
sheet.write(i,0,all['_id'])
sheet.write(i,1,all['text'])
sheet.write(i,2,all['user_id'])
sheet.write(i,3,all['geo']['coordinates'][0])
sheet.write(i,4,all['geo']['coordinates'][1])
sheet.write(i,5,all['created_at'])
i=i+1
if(i==65530):
break
book.save('Excel_Workbook.xls')
workshop 的写入方法十分简洁:使用write函数
write(i,j,data) ##i,j分别为excel的i行j列的位置。起始为0,0