定义、解析和修改二进制结构的pythonic方法
destructif的Python项目详细描述
destructify是一种python和纯python 3方法,用于表示二进制数据,允许您读写二进制 结构。您只需按如下方式创建一个类来指定结构:
classExampleStructure(destructify.Structure):some_number=destructify.IntegerField(default=0x13,length=4,byte_order='little',signed=True)length=destructify.IntegerField(length=1)data=destructify.FixedLengthField(length='length')
现在您可以分析自己的二进制数据:
example=ExampleStructure.from_bytes(b"\x01\x02\x03\x04\x0BHello world")print(example.data)# b'Hello world'
或编写自己的数据:
example2=ExampleStructure(data=b'How are you doing?')print(bytes(example2))# b'\x13\x00\x00\x00\x12How are you doing?'
文档
销毁文件可在https://destructify.readthedocs.io/en/latest/找到 或者在docs/目录中。
安装
destructify可在python包索引中找到:
pip install destructify
贡献
由于destructify是一个开源项目,因此许多形式的贡献都受到欢迎。可能的例子 贡献包括:
- 缺陷修补程序
- 新功能
- 文档改进
- 拉取请求的错误报告和审查
我们使用github跟踪问题和请求。你总是可以 submit an issue当你遇到不寻常的事情时。