import xlwt def excel_write(): # 创建工作簿 wb = xlwt.Workbook() # 创建工作表 ws = wb.add_sheet("CNY") # 填充数据 ws.write_merge(0, 1, 0, 5, "标题") # 合并,0,1行 0,5列合并 # 写入数据 data = (("Date", "英镑", "人名币", "港币", "日元", "美元"), ("01/01/2019", 8.72551, 1, 0.877885, 0.062722, 6.8759), ("02/01/2019", 8.72551, 1, 0.877885, 0.062722, 6.8759) ) for i, item in enumerate(data): for j, val in enumerate(item): ws.write(i+2, j, val) # 创建第二个表格 wsimage = wb.add_sheet("image") # x写入图片 wsimage.insert_bitmap(r"F:\test\image.bmp", 0, 0) # 保存 wb.save(r"F:\test\test_excel.xls") if __name__ == '__main__': excel_write()