Encode MIMEText as quoted printables

后端 未结 3 2059
情书的邮戳
情书的邮戳 2020-12-31 08:53

Python supports a quite functional MIME-Library called email.mime.

What I want to achieve is to get a MIME Part containing plain UTF-8 text to be encod

3条回答
  •  轮回少年
    2020-12-31 09:23

    You do not need your hack:

    import email
    
    # Construct a new charset which uses Quoted Printables (base64 is default)
    cs = email.charset.Charset('utf-8')
    cs.body_encoding = email.charset.QP
    
    m = email.mime.text.MIMEText(u'This is the text containing ünicöde', 'plain', _charset=cs)
    
    print(m.as_string())
    

提交回复
热议问题