【问题标题】:How to get rid of the 'new lines' symbols in the output at Python when retrieving emails? [duplicate]检索电子邮件时如何摆脱 Python 输出中的“新行”符号? [复制]
【发布时间】:2020-10-23 23:55:11
【问题描述】:

在使用 Python 检索电子邮件时,我们如何摆脱“换行”符号“(\r\n)”? 1

【问题讨论】:

标签: python newline


【解决方案1】:

使用

s = "ABCD\n\r"

s = s.replace("\n", "")
s = s.replace("\r", "")

print(s)

给出输出:

ABCD

使用replace 而不是strip,因为它不关心指定字符的位置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-05
    • 1970-01-01
    • 1970-01-01
    • 2016-08-21
    • 1970-01-01
    • 1970-01-01
    • 2017-03-20
    相关资源
    最近更新 更多