以下代码适用于Python2:fromctypesimport*##Setuppythonfile->c'FILE*'conversion:classFILE(Structure):passFILE_P=POINTER(FILE)PyFile_AsFile=pythonapi.PyFile_AsFile#problemherePyFile_AsFile.argtypes=[py_object]PyFile_AsFile.restype=FILE_Pfp=open(filename,'wb')gd.gdImagePng(img,PyFile_AsFile(fp))但是在Python3中,