Possible duplicate:encoding / decoding string
Now the object looks like this: =? UTF-8? B 0J / RgNC + 0LLQtdGA0LrQsA ==? =
The part between =?UTF-8?B? and ?= is a base64 encoded string. Extract this part, and then decrypt it.
=?UTF-8?B?
?=
import base64 #My buggy SSH account needs this to write unicode output, you hopefully won't import sys import codecs sys.stdout = codecs.getwriter('utf-8')(sys.stdout) encoded = '=?UTF-8?B?0J/RgNC+0LLQtdGA0LrQsA==?=' prefix = '=?UTF-8?B?' suffix = '?=' #extract the data part of the string middle = encoded[len(prefix):len(encoded)-len(suffix)] print "Middle: %s" % middle #decode the bytes decoded = base64.b64decode(middle) #decode the utf-8 decoded = unicode(decoded, 'utf8') print "Decoded: %s" % decoded
Output:
Middle: 0J/RgNC+0LLQtdGA0LrQsA== Decoded:
Perhaps you can use the decode_header function: http://docs.python.org/library/email.header.html#email.header.decode_header
Source: https://habr.com/ru/post/1343171/More articles:Django URL resolution does not work when starting Apache / WSGI - pythonCan I block the width or height of the MFC dialog while resizing? - c ++Jersey serializes inherited property twice - javaDrupal 7 Views - Customize RSS Output Template - viewsGet blank lines from pass validation - validationCan Node.js Applications Have Static URLs? - node.jsstring encoding / decoding - pythonSQLiteOpenHelper Error - androidPHP - How can I do my own human check? - phpInsert multiple rows into a table in asp.net MVC - asp.net-mvc-2All Articles