This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Struct pack()
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jimmy, mark.dickinson
Priority: normal Keywords:

Created on 2018-10-29 08:21 by jimmy, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg328794 - (view) Author: jimmy (jimmy) Date: 2018-10-29 08:21
The result of variable "a" should be b'30\x11\x00\x00' not b'0\x11\x00\x00' .

>>> import struct
>>> a = struct.pack("<i",4400)
>>> print(a)
b'0\x11\x00\x00'
>>>
msg328795 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2018-10-29 08:26
The result is correct. Note that the first character is "0", which is chr(48).

>>> '0' == '\x30'
True
>>> '0\x11\x00\x00' == '\x30\x11\x00\x00'
True
History
Date User Action Args
2022-04-11 14:59:07adminsetgithub: 79283
2018-10-29 08:26:28mark.dickinsonsetstatus: open -> closed

nosy: + mark.dickinson
messages: + msg328795

resolution: not a bug
stage: resolved
2018-10-29 08:21:02jimmycreate