gpt4 book ai didi

python - 如何删除从网站抓取的数据中的 "^M"?

转载 作者:搜寻专家 更新时间:2023-10-31 22:50:48 27 4
gpt4 key购买 nike

我有这样的数据:

"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在很多编辑器中用来表示回车符。您通常会键入 Ctrl + M 以在这些编辑器中生成该字符。

与大多数编程语言一样,Python 将此表示为 '\r'

关于python - 如何删除从网站抓取的数据中的 "^M"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5772773/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com