當前位置:成語大全網 - 新華字典 - python將數組寫入excel文件

python將數組寫入excel文件

# 將數據寫入新文件

def data_write(file_path, datas):

f = xlwt.Workbook()

sheet1 = f.add_sheet(u'sheet1',cell_overwrite_ok=True) #創建sheet

#將數據寫入第 i 行,第 j 列

i = 0

for data in datas:

for j in range(len(data)):

sheet1.write(i,j,data[j])

i = i + 1

f.save(file_path) #保存文件