Python ctypes: Python file object <-> C FILE *

前端 未结 6 761
深忆病人
深忆病人 2020-12-14 04:16

I am using ctypes to wrap a C-library (which I have control over) with Python. I want to wrap a C-function with declaration:

int fread_int( FILE * stream );
         


        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-14 05:13

    I've encountered the same problem.

    Take a look at this file:

    http://svn.python.org/projects/ctypes/trunk/ctypeslib/ctypeslib/contrib/pythonhdr.py

    You can use PyFile_AsFile from it.

提交回复
热议问题