不为别的,只为做一个连自己都羡慕的人

python向excel中写入超链接

# 向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')

 

posted @ 2022-02-09 10:29  升级打怪  阅读(1299)  评论(0编辑  收藏  举报