Problem!!

Chris Angelico rosuav at gmail.com
Sun Jul 3 19:54:28 EDT 2011


On Mon, Jul 4, 2011 at 9:41 AM, amir chaouki <chaouki.amir at gmail.com> wrote:
> i have written code on linux for parsing text files and it works great
> but when i try to run it on windows it goes crazy, do you have any
> idea???

If you share your code, we may be able to help. Alternatively, here's
a few differences to look at:

1) Filenames - if you have a literal for your file name,
"/home/foobar/file" will work, but "c:\path\newfile.txt" won't -
backslash is a special character. Make it a raw string:
r"c:\path\newfile.txt" - that will work.

2) End of line characters. If you divide the contents of the file on
the "\n" character, and then try to work with the end of each line,
you may find that the string has a "\r" character at the end.

3) What Irmen de Jong said. :)

Chris Angelico



More information about the Python-list mailing list