Я создаю код, который будет извлекать все подтвержденные выздоровления и смерти во всем мире. Я хочу, чтобы он был сохранен в файле xlsx (Line By Line), но весь учебник там не работал. это код, который я использую
from tkinter import *
from tkinter import messagebox
import COVID19Py
def confirmed_wrld():
conf_list = covid19.getLocations(rank_by='confirmed')
with open("confirmed.txt", 'w') as output:
for row in conf_list:
output.write(str(row) + '\n')
messagebox.showinfo('Saved','The list is saved in confirmed.txt file in the same folder if you dont have confirmed.txt file create one in the same directory and redo this action')
def recovered_wrld():
recovered_lst = covid19.getLocations(rank_by='recovered')
with open("recovered.txt", 'w') as output:
for row in recovered_lst:
output.write(str(row) + '\n')
messagebox.showinfo('Saved',"The list is saved in recovered.txt file in the same folder if you dont have recovered.txt file create one in the same directory and redo this action")
def deaths_wrld():
dth_lst = covid19.getLocations(rank_by='deaths')
messagebox.showinfo('Done', dth_lst)
with open("deaths.txt", 'w') as output:
for row in dth_lst:
output.write(str(row) + '\n')
messagebox.showinfo('Saved',"The list is saved in deaths.txt file in the same folder if you dont have deaths.txt file create one in the same directory and redo this action")
covid19 = COVID19Py.COVID19(data_source="csbs")
root = Tk()
root.geometry("500x500")
root.title("CoronaVirus Locator")
confirmed_BTN = Button(text="confirmed in the whole world", command = confirmed_wrld)
confirmed_BTN.pack()
recovered_BTN = Button(text="recovered in the whole world", command = recovered_wrld)
recovered_BTN.pack()
deaths_BTN = Button(text="deaths in the whole world", command = deaths_wrld)
deaths_BTN.pack()
root.mainloop()
, как вы можете видеть, я пытаюсь сохранить его как текстовый файл, он работает, но я хочу, чтобы он был в xlsx, чтобы другие люди могли легко его увидеть.