mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
25 lines
455 B
Python
25 lines
455 B
Python
|
|
import struct
|
|
|
|
data = struct.pack('IH', 14, 12)
|
|
assert data == bytes([14, 0, 0, 0, 12, 0])
|
|
|
|
v1, v2 = struct.unpack('IH', data)
|
|
assert v1 == 14
|
|
assert v2 == 12
|
|
|
|
data = struct.pack('<IH', 14, 12)
|
|
assert data == bytes([14, 0, 0, 0, 12, 0])
|
|
|
|
v1, v2 = struct.unpack('<IH', data)
|
|
assert v1 == 14
|
|
assert v2 == 12
|
|
|
|
data = struct.pack('>IH', 14, 12)
|
|
assert data == bytes([0, 0, 0, 14, 0, 12])
|
|
|
|
v1, v2 = struct.unpack('>IH', data)
|
|
assert v1 == 14
|
|
assert v2 == 12
|
|
|