Take a brief look at the code
def write2Excel(INFO, excel_path, sheet_name):
keys = list(INFO.keys()) # Get dictionary's key value
values = list(INFO.values()) # Get dictionary's value value
# print(keys)
# print(values)
book = xlwt.Workbook()
sheet = book.add_sheet(sheet_name)
# Write column name
for i in range(0, len(keys)):
sheet.write(0, i, keys[i])
# Write data
for j in range(0, len(values)):
sheet.write(1, j, values[j])
book.save(excel_path)
# Execution time
write2Excel(INFO, './Result/excel_02.xlsx', 'Sheet1')
The problem is : Invalid file format or file extension
It's very strange , do not know why , Then I found someone else's solution , Change the execution statement to :
write2Excel(INFO, './Result/excel_02.xls', 'Sheet1')
namely , hold .xlsx Replace the file with .xls File extension is ok .
Close test effectively , But I still don't understand why , First bury a pit , Then come back when you understand Update the answer .
If anyone who knows about it passes by and shares the reason for this problem , Thank you for .