python简单生成excel
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
import xlwt
def generate_excel(file_name, data):
work_book = xlwt.Workbook(encoding='utf-8')
sheet = work_book.add_sheet('sheet_name')
sheet.write(0, 0, 'title_name')
sheet.write(0, 1, 'title_name')
row_count = 0
for title_value1, title_value2 in data.items():
row_count += 1
sheet.write(row_count, 0, f'{title_value1}')
sheet.write(row_count, 1, f'{title_value2 }')
work_book.save(f'{file_name}.xls')