# 向excel中写数据 book = xlwt.Workbook(encoding='utf-8') # 创建Workbook,相当于创建Excel # 创建sheet,Sheet1为表的名字,cell_overwrite_ok为是否覆盖单元格 sheet1 = book.add_sheet(u'Sheet1', cell_overwrite_ok=True) for index, keya in enumerate(arr): con = keya["id"] + " " + keya["zh_title"] + " " + keya["time"] sheet1.write(index, 0, xlwt.Formula('HYPERLINK("{}", "{}"\r)'.format(keya["origin_url"], con))) book.save('test.xls')