I use the following code to write data to an excel file, but got nothing in the excel file. How can I get my desired output:
Code:
import xlsxwriter
workbook = xlsxwriter.Workbook('print_def.xlsx')
worksheet = workbook.add_worksheet()
tree = 'YES'
while i < 4:
worksheet.write(i, 0, tree) #nothing is written to the excel file
i+=1
workbook.close()
My desired output:
1 YES
2 YES
3 YES
4 YES
Question : How can I update the code for my desired output? Thanks in advance!
As pointed by @Lucvv, I forgot to put i=0
in the code, it then works after adding i=0
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.