Python ctypes: copying Structure's contents
问题 I want to mimic a piece of C code in Python with ctypes, the code is something like: typedef struct { int x; int y; } point; void copy_point(point *a, point *b) { *a = *b; } in ctypes it's not possible to do the following: from ctypes import * class Point(Structure): _fields_ = [("x", c_int),("y", c_int)] def copy_point(a, b): a.contents = b.contents p0 = pointer(Point()) p1 = pointer(Point()) copy_point(p0,p1) as the contents still is a Python ctypes Structure object, that is managed as a