# -*- coding: utf-8 -*-
import openpyxl as xl
import os
folder_path = 'C:/Users/wangj/gs/sip2/'
result_path = os.path.join(folder_path, "my.xlsx")
if os.path.exists(result_path):
workbook = xl.load_workbook(result_path)
else:
workbook = xl.Workbook()
workbook.save(result_path)
sheet = workbook.active
headers = ["URL", "predict", "score"]
#写第一行
sheet.append(headers)
result = [['1', 1, 1], ['2', 2, 2], ['3', 3, 3]]
#写内容
for data in result:
sheet.append(data)
workbook.save(result_path)
python 利用openpyx 写xlsx文件
最新推荐文章于 2024-07-24 19:58:49 发布