Python 3 replacement for PyFile_AsFile

后端 未结 2 1147
孤城傲影
孤城傲影 2020-12-06 18:22

The following code works in Python 2:

from ctypes import *

## Setup python file -> c \'FILE *\' conversion :
class FILE(Structure):
    pass
FILE_P = POI         


        
2条回答
  •  执笔经年
    2020-12-06 19:05

    I didn't find a real answer to the problem, but I found out that if you don't need to convert the Python file object to a FILE* (i.e., you don't need to "share" the opened file), you can just use ctypes to call fopen from libc and get the FILE* like that.

提交回复
热议问题