如何在python中解码这种奇怪的编码?

时间:2018-07-22 05:01:14

标签: python django string python-3.x decode

我正在使用移动运营商API。当我收到波斯语消息时,它会返回像这样的奇怪编码。

062a0633062a

此字符串表示波斯语中的تست。我知道每四个字符都是波斯字符的Unicode表示形式。

如何解码这种编码?

1 个答案:

答案 0 :(得分:2)

>>> binascii.unhexlify('062a0633062a').decode('utf-16be')
'تست'