Skip to content

Commit 4760cd9

Browse files
committed
add struct
1 parent 5c0e3b4 commit 4760cd9

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test_struct/test_struct.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import struct
2+
import ctypes
3+
4+
mm = struct.pack("hhl", 1, 2, 3)
5+
#mm = struct.pack("hhl01", 1,2,3) //padding
6+
nn = struct.unpack('hhl', mm)
7+
print mm, nn
8+
9+
mm = struct.calcsize('ci')
10+
nn = struct.calcsize('ic')
11+
print mm, nn
12+
13+
mm = ctypes.create_string_buffer(100)
14+
struct.pack_into('hhl', mm, 0, 1, 2, 3)
15+
print struct.unpack_from('hhl', mm, 0)

0 commit comments

Comments
 (0)