EOL created by .write or .encode

Xah Lee xah at xahlee.org
Tue Apr 5 01:58:38 EDT 2005


Why is that some of my files written out by
   outF.write(outtext.encode('utf-8'))
has ascii 10 as EOL, while others has ascii 13 as EOL?
both of these files's EOL are originally all ascii 10.

If i remove the EOL after the tt below in the place string, then this
doesn't happen.

findreplace = [
(ur'</body>',
ur'''tt
</body>'''),
]

...

   inF = open(filePath,'rb')
   s=unicode(inF.read(),'utf-8')
   inF.close()

   for couple in findreplace:
       outtext=s.replace(couple[0],couple[1])
       s=outtext
   outF = open(tempName,'wb')
   outF.write(outtext.encode('utf-8'))
   outF.close()

thanks.

 Xah
 xah at xahlee.orghttp://xahlee.org/PageTwo_dir/more.html


More information about the Python-list mailing list