[Newbie] line separators in file-output
Steve Purcell
stephen_purcell at yahoo.com
Wed Mar 21 09:40:57 EST 2001
Daniel Orlowski wrote:
> If I in Python uder Windows do smth like this:
>
> >>> File=open("test","w")
> >>> File.write("a line"+"\n")
> >>> File.close()
>
> I have data in file test:
> 'a line\015\012'
>
> How can I prevent output of '\015'?
Open the file in binary mode: File = open('test','wb')
Windows automatically changes line endings for files opened in text mode.
-Steve
--
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Any opinions expressed herein are my own and not necessarily those of Yahoo
More information about the Python-list
mailing list