跳转到主要内容

hexbytes: Python `bytes`子类,可以解码十六进制,具有可读的控制台输出

项目描述

HexBytes

Join the conversation on Discord Build Status PyPI version Python versions Docs build

Python bytes 子类,可解码十六进制,具有可读的终端输出

阅读文档

查看变更日志

快速开始

python -m pip install hexbytes
# convert from bytes to a prettier representation at the console
>>> HexBytes(b"\x03\x08wf\xbfh\xe7\x86q\xd1\xeaCj\xe0\x87\xdat\xa1'a\xda\xc0 \x01\x1a\x9e\xdd\xc4\x90\x0b\xf1;")
HexBytes('0x03087766bf68e78671d1ea436ae087da74a12761dac020011a9eddc4900bf13b')

# HexBytes accepts the hex string representation as well, ignoring case and 0x prefixes
>>> hb = HexBytes('03087766BF68E78671D1EA436AE087DA74A12761DAC020011A9EDDC4900BF13B')
HexBytes('0x03087766bf68e78671d1ea436ae087da74a12761dac020011a9eddc4900bf13b')

# get the first byte:
>>> hb[0]
3

# show how many bytes are in the value
>>> len(hb)
32

# cast back to the basic `bytes` type
>>> bytes(hb)
b"\x03\x08wf\xbfh\xe7\x86q\xd1\xeaCj\xe0\x87\xdat\xa1'a\xda\xc0 \x01\x1a\x9e\xdd\xc4\x90\x0b\xf1;"

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

hexbytes-1.2.1.tar.gz (7.7 kB 查看哈希值)

上传时间 源代码

构建分发

hexbytes-1.2.1-py3-none-any.whl (5.2 kB 查看哈希值)

上传时间 Python 3

支持者