【发布时间】:2011-04-25 03:47:11
【问题描述】:
我的数据如下所示:
"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”。这是一个“回车”,最初被选为告诉打印机将“马车”(携带打印头的东西)返回到页面左边缘的字符。