imaplib - how do I convert text containing \r\n to represent carriage return and line feed in python -


i have written code in python using imapclient , poplib collect emails online account. received emails saved plain text file.

when email using pop3 saved in text file carriage returns , line spacings in correct place. believe because pop3 emails saved line line automatically implement carriage returns each new line.

imap on other hand not friendly. imap text contains \r\n occasional \t, when view text file in vi, notepad, wordpad , word, none of them implement carriage return, linefeed or tabs.

from i've read reason because programs see \r\n text , don't know it.

so question is, how convert imap text \r\n seen in windows , linux using python.

thanks.

try email_content.decode('string_escape').

example:

>>> s = r'a\tb\nc' >>> print s.decode('string_escape')   b c 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -