0
Hallo!python(ctypes)的Blob對象,C++
我想要一個blob對象,我可以在python中傳遞這些對象,並不時給它一個C++函數來寫入。
ctypes似乎要走的路,但我有python標準函數的問題。
例如:
>>> import ctypes
>>> T=ctypes.c_byte * 1000
>>> blob = T()
>>> ctypes.pointer(blob)
<__main__.LP_c_byte_Array_1000 object at 0x7f6558795200>
# Do stuff with blob data through the pointer in C++
>>> f = open('test.bin', 'wb')
>>> f.write(blob)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: argument 1 must be string or buffer, not _ctypes.ArrayType
我真的想避免,如果沒有必要的複製數據。
感謝
感謝您使用字符串緩衝區和訪問內容運氣比較好,問題就解決了,我認爲:) – tauran 2010-08-26 15:58:42