我有一个看起来像这样的数据:我如何摆脱我从网站上刮掉的数据中的“^ M”?
"1964 iwanttoholdyourhand beatles
^M
oh yeah, i'll tell you something
i think you'll understand
when i'll say that something
i wanna hold your hand
i wanna hold your hand
i wanna hold your hand
oh please, say to me
you'll let me be your man
and please, say to me
you'll let me hold your hand
i'll let me hold your hand
i wanna hold your hand"
我试图摆脱^ M的,所以我尝试使用应用re.sub但没有找到它 - 我认为这是一些特殊字符,而不是实际上彼此相邻的“^”和“M”。关于如何删除它的任何想法? 谢谢!
在正则表达式或字符串中,“^ M”字符通常被称为“\ r”。这是一个“回车”,最初被选为将告诉打印机将“托架”(携带打印头的东西)返回到页面左边的字符。 – Pointy 2011-04-24 19:46:05