Removing ^M

Sean 'Shaleh' Perry shalehperry at attbi.com
Sat Jun 8 11:16:40 EDT 2002


> 
> There's a program called dos2unix that will do this. From your mail
> headers it looks to me like you have a Unix/Linux system in which case
> it may already be installed. If not do a google search on dos2unix.
> 

another possibility is fromdos (and its brother todos).

As Chris Gonnerman pointed out ^M is '\r' or 'carriage return'.  Under Windows
every line ends in '\r\n', under Unix it is just '\n' and I think Macs only use
'\r'.  This is usually hidden from you because python, the C libs, etc all know
how to translate behind the scenes.

If you have some one at work (or a friend) ftp'ing files have them set the mode
to ASCII before transfer and FTP will do the conversion for you.





More information about the Python-list mailing list