【发布时间】:2014-08-04 16:16:40
【问题描述】:
我一直在尝试去除字符串中单词前后的 \n 加上空格,但由于某种原因它不起作用。
这是我尝试过的:
.strip(my_string)
和
re.sub('\n', '', my string)
我曾尝试使用.strip 和re 以使其正常工作,但它只是返回相同的字符串。
示例输入:
\\n The people who steal our cards already know all of this...\\n
\\n , \\n I\'m sure every fraud minded person in America is taking notes.\\n
\\n
预期的输出是:
The people who steal our cards already know all of this..., I\'m sure every fraud minded person in America is taking notes.
【问题讨论】:
-
您需要出示您的代码
-
您是要删除一个实际的换行符
\n,还是删除\字符后跟n字符? -
请附上您自己的尝试,并告诉我们如何它不起作用。包括您收到的任何错误消息。
-
我其实不知道里面有人物
-
并添加预期的输出。
标签: python regex newline strip