I am having a bitfield structure in C and i want to implement the same in python. With the structure i am having in C i am able to get 2 byte of data through it..and i write this data in a file in binary format.. The same thing i want to implement with python but i am not able to get any fruitful solution till now.. The structure for the C is as follows:
struct test {
unsigned int x : 5;
unsigned int y: 3;
unsigned int z : 8;
};
Please help me with the above mentioned issue.. Thanks in Advance
To be more precise i am having a structure as below which i am writing in a binary file
typedef struct abc{
unsigned int year :12;
unsigned int Month :4;
unsigned int Date :5;
unsigned int Hour :5;
unsigned int Min :6;
unsigned int Sec :6;
unsigned int w :1;
unsigned int x :1;
unsigned int y :8;
unsigned int z :8;
unsigned int q :8;
}abc ;
i am filling the structure as follows:
abc.year=2020
abc.Month=2
abc.Date=31
abc.Hour=12
abc.Min=45
abc.Sec=25
abc.w=0
abc.x=1
abc.y=145
abc.z=100
abc.q=120
The output i am getting in the output file is as follows: E4 27 9F B5 99 91 64 78
The same thing i need to do with python..so please help me with this