IMAP folder path encoding (IMAP UTF-7) for Python

前端 未结 4 1662
感动是毒
感动是毒 2020-12-19 05:15

I would like to know if any \"official\" function/library existed in Python for IMAP4 UTF-7 folder path encoding.

In the imapInstance.list() I get the f

4条回答
  •  余生分开走
    2020-12-19 05:45

    You may use imap_tools package: https://pypi.org/project/imap-tools/

    from imap_tools.imap_utf7 import encode, decode
    print(encode('привет'))
    >>> b'&BD8EQAQ4BDIENQRC-'
    print(decode(b'&BD8EQAQ4BDIENQRC-'))
    >>> привет
    
    print(repr(decode(encode("foo\rbar\n\n\n\r\r"))))
    'foo\rbar\n\n\n\r\r'
    

提交回复
热议问题