\r\n or \n notepad editor end line ???
Max M
maxm at mxm.dk
Wed Jun 8 09:32:09 EDT 2005
ajikoe at gmail.com wrote:
> Hello,
>
> I use windows notepad editor to write text.
>
> For example I write (in d:\myfile.txt):
> Helo
> World
>
> If I open it with python:
> FName = open(d:\myfile.txt,'r')
> h = FName.readlines()
> print h
>
> I get h : ['Helo\n', 'World']
>
> I thought notepad use \r\n to to end the line.
>
> What's wrong with it?
Python tries to be clever. Open it in binary mode to avoid it:
FName = open(d:\myfile.txt,'rb')
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
More information about the Python-list
mailing list