hex bytes:python“bytes”子类,解码十六进制,具有可读的控制台输出
hexbytes的Python项目详细描述
十六字节
pythonbytes
解码十六进制的子类,具有可读的控制台输出
阅读documentation on ReadTheDocs中的更多内容View the change log
快速启动
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,请查看Snake Charmers Tactical Manual 有关我们如何做的信息:
- 测试
- 拉取请求
- 代码样式
- 文件
开发环境设置
您可以使用以下命令设置开发环境:
git clone git@github.com:carver/hexbytes.git cd hexbytes virtualenv -p python3 venv . venv/bin/activate pip install -e .[dev]
测试设置
在开发过程中,您可能希望在每次保存文件时都运行测试。
更改文件时显示flake8错误:
# Test flake8 when-changed -v -s -r -1 hexbytes/ tests/ -c "clear; flake8 hexbytes tests && echo 'flake8 success' || echo 'error'"
在一个命令中运行多进程测试,但不使用颜色:
# in the project root: pytest --numprocesses=4 --looponfail --maxfail=1# the same thing, succinctly: pytest -n 4 -f --maxfail=1
在一个线程中运行,带有颜色和桌面通知:
cd venv ptw --onfail "notify-send -t 5000 'Test failure ⚠⚠⚠⚠⚠' 'python 3 test on hexbytes failed'" ../tests ../hexbytes
释放设置
对于类似Debian的系统:
apt install pandoc
发布新版本:
make release bump=$$VERSION_PART_TO_BUMP$$
如何颠簸
此回购协议的版本格式为{major}.{minor}.{patch}
,表示稳定,并且
{major}.{minor}.{patch}-{stage}.{devnum}
表示不稳定(stage
可以是α或β)。
要发布第行的下一个版本,请指定要凹凸的部分,
比如make release bump=minor
或者make release bump=devnum
。这通常是从
主分支,除了发布beta(在这种情况下,beta是从主分支发布的,
上一个稳定的分支从所述分支释放)。包括对每个
发布,用更改更新“docs/releases.rst”,并直接向master应用commit
在释放之前。
如果您是beta版,make release bump=stage
将切换到稳定版。
若要在当前版本稳定时发布不稳定版本,请指定
新版本,如make release bump="--new-version 4.0.0-alpha.1 devnum"