I have 2 questions about struct in the python documentation:
Byte Order, Size, and Alignment : For Network communication should i use ! instead of = ?
eg: struct.pack("!BBH", 1, 12, 512) or struct.pack("=BBH", 1, 12, 512) ?
Format characters : What is the difference between unsigned int (I) and unsigned long (L), since both are 4 bytes?
Thank you for your time, and forgive me if its a silly question 🙂
If you want your code to produce the same output wherever it is run, why would you ever use
=? So of course, yes, you should use a code that means the same thing to everyone. The standard is!so use!.Read the header above the format code table:
So, if you use the
@format code or omit the format code, the size ofIand the size ofLcould theoretically be different, depending on your platform.