x = '=?gb2312?B?uLGxvmhlbrixsb5nLnhscw==?='
try:
    name = ''.join([str(b, e or 'ascii') for b, e in email.header.
        decode_header(x)])
except email.Errors.HeaderParseError:
    pass
how to tell if a string is base64 or not