faqts : Computers : Programming : Languages : Python : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 9 people (78%) answered Yes
Recently 2 of 4 people (50%) answered Yes

Entry

How do I place a newline into the win32file.WriteFile (wHandle, string) method?

May 18th, 2000 07:48
unknown unknown, Laurent POINTAL


A solution which works for all platforms:
        import os
        ...#open the file in binary mode.
        file.write(os.linesep)

If you have opened your file with the text mode, then an \n is
normally translated into a \r\n when writing to the file (and reverse
when reading). Maybe it works also for the Macintosh (translating \n
to \r and reverse).

[Note: os miscellanenous system data allows you to relatively be
independant of host os -- see Help chapter 6.1.6]