On Mon, Nov 11, 2013 at 5:26 PM, Matt <[email protected]> wrote:
> So I want to take the file, "desktop/test.txt" and write it to
> "desktop/newfolder/test.txt". I tried the below script, and it gave me:
> "IOError: [Errno 2] No such file or directory: 'desktop/%s.txt'". Any
> suggestions would be great.
Its better in the future to cut and paste the traceback rather than
paraphrase...
That being said, it can't find the in_file. Maybe you aren't in the
directory above desktop? Try specifying a complete path, instead of
relative. Once you solve that, be sure the ouput path is specificed
completely and that it exists.
>
>
>
> def firstdev(file):
> in_file = open("desktop/%s.txt") % file
> indata = in_file.read()
> out_file = open("desktop/newfolder/%s.txt", 'w') % file
> out_file.write(indata)
> out_file.close()
> in_file.close()
>
> firstdev("test")
> --
> https://mail.python.org/mailman/listinfo/python-list
--
Joel Goldstick
http://joelgoldstick.com
--
https://mail.python.org/mailman/listinfo/python-list