I am working a image build project, I am trying to use python to create a structure,
I know c is very easy to create a data structure, here is a c example.
struct Books {
char title[50];
char author[50];
char subject[100];
uint32_t book_id;
uint8_t book_ver;
uint16_t book_location;
};
void main( ) {
FILE *fptr;
struct Books Book1; /* Declare Book1 of type Book */
strcpy( Book1.title, "C Programming");
strcpy( Book1.author, "Anna Ali");
strcpy( Book1.subject, "C Programming Tutorial");
Book1.book_id = 649507;
Book1.book_ver = 2;
Book1.book_location= 308;
fptr = fopen("book_struct.bin","wb");
fwrite(&Book1, sizeof(struct Books), 1, fptr);
fclose(fptr);
}
How can I create a data struct binary file in python? Can someone help to provide a python reference code?