Alex Rivera | Logout

How to remove ^M

Asked 2010-07-07T01:23:51.360
14

How can I remove the ^M character from a text file (at the end of line) in a Python script?

I did the following, and there are ^M at every line-break.

file = open(filename, "w")
file.write(something)
Edit
Report

1 Answer

7

string.replace('\r', '') worked for me.

Ugly, but nor r+ nor r+b nor NOTHING ELSE worked (for me, sure) :(

answered 2013-02-28T14:33:00.833

Your Answer