Вопрос по python – Декодировать строку base64 в Python 3 (с lxml или нет)

9

Error: User Rate Limit Exceededbytes-str-unicodeError: User Rate Limit Exceededencoding-decodingчестно говоря) мелочи пока нет.

Error: User Rate Limit ExceededlxmlError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Я получаю двоичные данные с помощью запроса XPath'.../binary/text()'Error: User Rate Limit Exceededlxml.etree._ElementUnicodeResult объект. Затем с Python 2 я смог сделать:

decoded = source.decode('base64')

Error: User Rate Limit Exceeded

output = numpy.frombuffer(decoded)

Error: User Rate Limit Exceeded

AttributeError: 'lxml.etree._ElementUnicodeResult' object has no attribute 'decode'

Error: User Rate Limit Exceededlxml.etree._ElementUnicodeResultError: User Rate Limit Exceededstr.

Error: User Rate Limit ExceededstrError: User Rate Limit Exceeded

 binary = tree.xpath('//binary')[0]
 binary_string = binary.text

Error: User Rate Limit Exceededbase64Error: User Rate Limit ExceededbytesError: User Rate Limit Exceededstr какbytesError: User Rate Limit ExceededbytesError: User Rate Limit ExceededencodeError: User Rate Limit Exceeded

Error: User Rate Limit ExceededbinasciiError: User Rate Limit Exceededbase64Error: User Rate Limit Exceededbinascii.b2a_base64()Error: User Rate Limit Exceeded

TypeError: 'str' does not support the buffer interface

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceededbytes.fromhex()Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededError: User Rate Limit Exceeded.

Error: User Rate Limit ExceededPragmatic Unicode, or: How Do I Stop the Pain? user395760
Error: User Rate Limit Exceeded Lev Levitsky

Ваш Ответ

2   ответа
7

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit ExceededError: User Rate Limit Exceeded).


Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededstrError: User Rate Limit ExceededunicodeError: User Rate Limit Exceeded

Error: User Rate Limit ExceededstrError: User Rate Limit ExceededbytesError: User Rate Limit Exceeded


Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededbytesError: User Rate Limit ExceededfloatError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded


Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceededbase64.b64decode()Error: User Rate Limit Exceededbyte stringError: User Rate Limit ExceededstrError: User Rate Limit ExceededbytesError: User Rate Limit ExceededstrError: User Rate Limit Exceeded

>>> s = 'U3RhY2sgT3ZlcmZsb3c='

Error: User Rate Limit Exceeded

>>> s.decode('base64')

Error: User Rate Limit ExceededsError: User Rate Limit Exceededencode it in ASCIIError: User Rate Limit Exceeded

>>> base64.b64decode(s.encode('ascii'))

Error: User Rate Limit ExceededbytesError: User Rate Limit ExceededstrError: User Rate Limit ExceededstructError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

>>> base64.b64decode(s.encode('ascii')).decode('ascii')

Error: User Rate Limit Exceededencode('ascii')Error: User Rate Limit ExceededstrError: User Rate Limit Exceededimplicit conversionError: User Rate Limit Exceededdecode('ascii')Error: User Rate Limit ExceededunicodeError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceedednumpy.frombuffer()Error: User Rate Limit Exceededstruct для справки, для учета общего случая. Lev Levitsky
Error: User Rate Limit Exceeded Lev Levitsky
2

Error: User Rate Limit Exceeded

Черт возьми ... Я знал, что это легко. Я просто не могу уладить все это в уме так, как должно быть. Я думал о своей строке как о чем-тоencodedError: User Rate Limit Exceededbytes, Благодарю. Lev Levitsky
Error: User Rate Limit Exceeded
Я чувствовал, что такой длинный вопрос нуждается в более длинном ответе, но в любом случае, большое спасибо за указание правильного направления :) Lev Levitsky

Похожие вопросы