import base64
a = base64.b64encode(bytes(u’complex string: ñáéíóúÑ’, «utf-8»))
# a: b’Y29tcGxleCBzdHJpbmc6IMOxw6HDqcOtw7PDusOR’
b = base64.b64decode(a).decode(«utf-8», «ignore»)
print(b)
# b :complex string: ñáéíóúÑ
import base64
a = base64.b64encode(bytes(u’complex string: ñáéíóúÑ’, «utf-8»))
# a: b’Y29tcGxleCBzdHJpbmc6IMOxw6HDqcOtw7PDusOR’
b = base64.b64decode(a).decode(«utf-8», «ignore»)
print(b)
# b :complex string: ñáéíóúÑ