Python Fails to Write to File
cutey Love
cuteywithlove at gmail.com
Thu Jun 19 03:54:37 EDT 2014
Thank you very much, that fixed it.
On Thursday, June 19, 2014 12:03:43 AM UTC+1, cutey Love wrote:
> 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
More information about the Python-list
mailing list