pytyon 保存到execl 【python】
pytyon 保存到execl def save_to_excel():
63 f_name = '淘宝%s数据'%KEYWORD
64 book = xlwt.Workbook(encoding='utf-8',style_compression=0)
65 sheet = book.add_sheet(f_name)
66 sheet.write(0, 0, 'title')
67 sheet.write(0, 1, 'price')
68 sheet.write(0, 2, 'sales')
69 sheet.write(0, 3, 'isTmall')
70 sheet.write(0, 4, 'area')
71 sheet.write(0, 5, 'name')
72 sheet.write(0, 6, 'url')
73 for i in range(len(DATA)):
74 sheet.write(i+1, 0, DATA[i]['title'])
75 sheet.write(i+1, 1, DATA[i]['price'])
76 sheet.write(i+1, 2, DATA[i]['sales'])
77 sheet.write(i+1, 3, DATA[i]['isTmall'])
78 sheet.write(i+1, 4, DATA[i]['area'])
79 sheet.write(i+1, 5, DATA[i]['name'])
80 sheet.write(i+1, 6, DATA[i]['url'])
81 book.save('淘宝%s数据.xls'%KEYWORD)
82
查看评论 回复