定义、解析和修改二进制结构的pythonic方法

destructif的Python项目详细描述


https://img.shields.io/travis/com/ralphje/destructify.svghttps://img.shields.io/codecov/c/github/ralphje/destructify.svg?style=flathttps://img.shields.io/pypi/v/destructify.svghttps://img.shields.io/readthedocs/destructify.svg

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当你遇到不寻常的事情时。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java例外。Lang.Stringindexoutofboundsexception索引超出范围(0)   java Spring引导Freemarker从2.2.0升级失败   重构Java反模式名称?包含对象的对象包含。。。等   用java处理JDBC可能出现的死锁的最佳方法   java无法访问主线程上的数据库,因为它可能会在很长一段时间内锁定UI   java如何将固定大小的画布包装在边框窗格中的滚动窗格居中?   java解析xsd文件后得到空结果   在html页面中表示XML文件的java   socketjava对象流   sql Java越界异常数据库   JavaJBoss7.1.1不会在Mavericks上启动   Twincat ADS事件驱动读取在一段时间后停止工作(Java)   java MyBatis使用生成的ID插入所有   Mojave上缺少MacOS Java控制面板   JavaGuice:如果多次注入相同的依赖项,是否注入了该依赖项的相同实例?