Removing ^M

Magnus Lie Hetland mlh at vier.idi.ntnu.no
Sat Jun 8 17:56:15 EDT 2002


In article <mailman.1023546912.19781.python-list at python.org>, Michael
Hall wrote:
>
>I am trying remove ^M characters (some kind of newline character) from an
>HTML file. I've tried all sorts of string.replace and sed possibilities
>but the
>things just won't go away. Does anyone have a way of removing such
>characters?

If you happen to run on a Windows system (including Cygwin) you could
simply do this:

  open('outfile', 'wb').write(open('infile').read())

Python will then take care of the translation for you.

>TIA 
>
>Mick

--
Magnus Lie Hetland                                  The Anygui Project
http://hetland.org                                  http://anygui.org



More information about the Python-list mailing list