I get a string from a function that is represented like u'xd0xbcxd0xb0xd1x80xd0xbaxd0xb0'
, but to process it I need it to be bytestring (like 'xd0xbcxd0xb0xd1x80xd0xbaxd0xb0'
).
How do I convert it without changes?
My best guess so far is to take s.encode('unicode_escape')
, which will return '\xd0\xbc\xd0\xb0\xd1\x80\xd0\xba\xd0\xb0'
and process every 5 characters so that 'xd0' becomes one character represented as 'xd0'.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…