直接上代码:
import xlsxwriter #导入模块
import numpy as np
import json
workbook = xlsxwriter.Workbook('new_excel.xlsx') #新建excel表
worksheet = workbook.add_worksheet('sheet1') #新建sheet(sheet的名称"sheet1")
data = np.ones((100,200),np.uint8)#这里可以换成你想存储的数据
shape = np.shape(data)
for indexrow in range(shape[0]):
print(indexrow)
rowdata = json.loads(str(data[indexrow,:].tolist()))
head = 'A'+str(indexrow+1)
worksheet.write_row(head,rowdata)
workbook.close()
运行结果如下图所示,可以把data
变量换成你想存储的二维数组。