我想用python创建我自己的自定义复杂数据结构。以下是相同的格式。在
DownloadInfoIndication () {
dsmccMessageHeader () {
protocolDiscriminator 8 bits
messageId 16 bits
transactionId 32 bits
adaptationLength 8 bits
messageLength 16 bits
if (adaptation length > 0) {
dsmccAdaptationHeader () adaptationLength
}
}
downloadId 32 bits
windowSize 8 bits (0x00)
tCDownloadWindow 32 bits (0x00)
tCDownloadScenario 32 bits
numberOfModules 16 bits
for (i = 0; i < numberOfModules; i++) {
moduleId 16 bits
moduleSize 32 bits
moduleVersion 8 bits
moduleInfoLength 8 bits
for (j = 0; j < moduleInfoLength; j++) {
moduleInfoByte moduleInfoLength
}
}
privateDataLength 16 bits
DescriptorCount 8 bits
for (k = 0; k < DescriptorCount; k++) {
tag 8 bits
length 8 bits
data length
}
}
我试着研究struct模块,但没有找到任何类似格式的示例。谁能帮忙吗。在
不完全确定你的用例是什么,但乍一看,它似乎可以通过使用OOP(面向对象编程)来处理。一个简单的类就足够了。在
看看Python文档:https://docs.python.org/3/tutorial/classes.html。在
相关问题 更多 >
编程相关推荐