File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,8 +101,8 @@ \section{Built-in Module \sectcode{struct}}
101101
102102Standard size and alignment are as follows: no alignment is required
103103for any type (so you have to use pad bytes); short is 2 bytes; int and
104- long are 4 bytes. In this mode, there is no support for float and
105- double ( \code {'f'} and \code {'d'}) .
104+ long are 4 bytes. Float and double are 32-bit and 64-bit IEEE floating
105+ point numbers, respectively .
106106
107107Note the difference between \code {'@'} and \code {'='}: both use native
108108byte order, but the size and alignment of the latter is standardized.
@@ -119,10 +119,14 @@ \section{Built-in Module \sectcode{struct}}
119119big-endian machine):
120120
121121\bcode \begin {verbatim }
122- from struct import *
123- pack('hhl', 1, 2, 3) == '\000\001\000\002\000\000\000\003'
124- unpack('hhl', '\000\001\000\002\000\000\000\003') == (1, 2, 3)
125- calcsize('hhl') == 8
122+ >>> from struct import *
123+ >>> pack('hhl', 1, 2, 3)
124+ '\000\001\000\002\000\000\000\003'
125+ >>> unpack('hhl', '\000\001\000\002\000\000\000\003')
126+ (1, 2, 3)
127+ >>> calcsize('hhl')
128+ 8
129+ >>>
126130\end {verbatim }\ecode
127131
128132Hint: to align the end of a structure to the alignment requirement of
Original file line number Diff line number Diff line change @@ -101,8 +101,8 @@ \section{Built-in Module \sectcode{struct}}
101101
102102Standard size and alignment are as follows: no alignment is required
103103for any type (so you have to use pad bytes); short is 2 bytes; int and
104- long are 4 bytes. In this mode, there is no support for float and
105- double ( \code {'f'} and \code {'d'}) .
104+ long are 4 bytes. Float and double are 32-bit and 64-bit IEEE floating
105+ point numbers, respectively .
106106
107107Note the difference between \code {'@'} and \code {'='}: both use native
108108byte order, but the size and alignment of the latter is standardized.
@@ -119,10 +119,14 @@ \section{Built-in Module \sectcode{struct}}
119119big-endian machine):
120120
121121\bcode \begin {verbatim }
122- from struct import *
123- pack('hhl', 1, 2, 3) == '\000\001\000\002\000\000\000\003'
124- unpack('hhl', '\000\001\000\002\000\000\000\003') == (1, 2, 3)
125- calcsize('hhl') == 8
122+ >>> from struct import *
123+ >>> pack('hhl', 1, 2, 3)
124+ '\000\001\000\002\000\000\000\003'
125+ >>> unpack('hhl', '\000\001\000\002\000\000\000\003')
126+ (1, 2, 3)
127+ >>> calcsize('hhl')
128+ 8
129+ >>>
126130\end {verbatim }\ecode
127131
128132Hint: to align the end of a structure to the alignment requirement of
You can’t perform that action at this time.
0 commit comments