代码之家  ›  专栏  ›  技术社区  ›  Milad Khodabandehloo

如何用python解码wierd编码?

  •  2
  • Milad Khodabandehloo  · 技术社区  · 6 年前

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

    062a0633062a
    

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

    我如何解码这种编码?

    1 回复  |  直到 6 年前
        1
  •  2
  •   Ignacio Vazquez-Abrams    6 年前
    >>> binascii.unhexlify('062a0633062a').decode('utf-16be')
    'تست'