ITeye博客

hexadecimal string to byte array in python

standalone · 2017-09-25 09:58 · 编程语言 · Markdown

hex_string = "deadbeef" Convert it to a string (Python ≤ 2.6):

hex_data = hex_string.decode("hex") hex_data "\xde\xad\xbe\xef" or since Python 2.7 and Python 3.0:

bytearray.fromhex(hex_data) bytearray(b'\xde\xad\xbe\xef')

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。