How can I change newline code?

Steve Purcell stephen_purcell at yahoo.com
Wed Feb 7 03:56:56 EST 2001


stksee at yahoo.co.jp wrote:
> 
> It seems "\n" is treated as LF.
> 
> Instead, I want to set "\n" as "CRLF" in string object.
> What should I do ?


'\n' will always be LF.  You should use 'os.linesep' to get the right
end-of-line character(s) for the machine running your program:

 >>> import os
 >>> os.linesep
 '\012'


-Steve

-- 
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Available for consulting and training.
"Even snakes are afraid of snakes." -- Steven Wright




More information about the Python-list mailing list