Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73403
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2014-06-19 00:54 -0700 |
| References | <8aaa4195-af5c-4ba3-a891-b1f268c086ac@googlegroups.com> |
| Message-ID | <627b76ee-b5e1-4969-b8e3-ff5b9bbcf97b@googlegroups.com> (permalink) |
| Subject | Re: Python Fails to Write to File |
| From | cutey Love <cuteywithlove@gmail.com> |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python Fails to Write to File cutey Love <cuteywithlove@gmail.com> - 2014-06-18 16:03 -0700
Re: Python Fails to Write to File Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-18 17:18 -0600
Re: Python Fails to Write to File Paul McNett <paul@mcnettware.com> - 2014-06-18 16:20 -0700
Re: Python Fails to Write to File cutey Love <cuteywithlove@gmail.com> - 2014-06-19 00:54 -0700
Re: Python Fails to Write to File Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-06-19 09:39 +0100
csiph-web