# pystruct **Repository Path**: hocker/pystruct ## Basic Information - **Project Name**: pystruct - **Description**: 该项目是为了将c语言的数据结构转换为 python 所用 - **Primary Language**: Python - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-01 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # c语言结构体转换为 python struct 字符描述 python 的struct 处理二进制数据如 c 语言的结构体, 怎么直接将 结构体转换为 struct 是这个项目的目的。 ## 说明 折腾了两天,算是一个小结,目前不支持嵌套结构体,不支持enum和一些复杂的东东。 额,啥,注释也还不支持。 恩恩,这个确实是我懒了,后面有时间再来填上吧。 ## 运行 ```bash cd src python pystruct.py ``` 大家可以嵌入到项目中,我就没得必要弄一个很好的目录结构了,本身就很简单。 ## 运行实例 ```c struct Header { unsigned short id; char tag[4]; unsigned int version; unsigned int count; }; struct Header2 { unsigned short id; char tag[4]; unsigned int version; unsigned int count; int ab; int eeee; struct Header aabb[4]; }; ``` ```bash ... ... "struct": { "Header": { "@key": "H4cII", "@arg": { "id": "H", "tag": "4c", "version": "I", "count": "I" } }, "Header2": { "@key": "H4cIIiiH4cIIH4cIIH4cIIH4cII", "@arg": { "id": "H", "tag": "4c", "version": "I", "count": "I", "ab": "i", "eeee": "i", "aabb": [ { "id": "H", "tag": "4c", "version": "I", "count": "I" }, { "id": "H", "tag": "4c", "version": "I", "count": "I" }, { "id": "H", "tag": "4c", "version": "I", "count": "I" }, { "id": "H", "tag": "4c", "version": "I", "count": "I" } ] } } } } ``` ## 其他 欢迎大家 到 我的 [博客]( https://blog.csdn.net/u012939880) 留言交流 .