如何在Python 3中使用或转换C中的fgetc()函数?

如何在Python 3中使用或转换C中的fgetc()函数?,c,python-3.x,fgetc,C,Python 3.x,Fgetc,我想在Python 3中使用C中的fgetc()函数。我想我必须使用: ord(fp.read(1))但我不确定。更具体地说,我想将以下代码从C转换为Python3: for(i=0;i<xdimension;i++) { for(j=0;j<ydimension;j++) { temp=1.164 * (fgetc(fp) - 16); if (temp>255) { temp=255 ; } if(i>

我想在Python 3中使用C中的fgetc()函数。我想我必须使用:
ord(fp.read(1))
但我不确定。更具体地说,我想将以下代码从C转换为Python3:

for(i=0;i<xdimension;i++)
{
    for(j=0;j<ydimension;j++)
    {
        temp=1.164 * (fgetc(fp) - 16);
        if (temp>255) { temp=255 ; } 
        if(i>=N || j>=M) { printf("i=%d,j=%d\n",i,j);}
        framed[i*M+j]=temp;
    }
}
(i=0;i=N | | j>=M){printf(“i=%d,j=%d\N,i,j);} 框架[i*M+j]=温度; } }
fgetc()所做的一切都是读取一个字节的数据,您可以使用read(0,buf,1),然后使用buf[0]或任何版本的read python使用。发布
temp
framed[]
的声明。fgetc()所做的一切都是读取一个字节的数据,您可以使用read(0,buf,1)然后使用buf[0]或者read python使用的任何版本。发布
temp
framed[]
的声明。