I'm trying to write data to a text file

But I'm getting the error:

TypeError: invalid file: <_io.TextIOWrapper 

Code is 

def saveFile():
    file_path = filedialog.asksaveasfile(mode='w', filetypes=[('text files', 
'.txt')], defaultextension=".txt")
    fo = open(file_path, 'w')
    
    for e in myList:
        fo.write(e)
            
    
    fo.close()

The file is being created if not already present but no data is written
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to