如何在python中创建复杂的数据结构

2024-09-29 05:29:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用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模块,但没有找到任何类似格式的示例。谁能帮忙吗。在


Tags: 数据结构for格式lengthbitstransactionidmessageidmessagelength