我应该在文件中保留一个偏移并读取该偏移线并发出,更新offset = offset + 1
with open(self.f) as f:
TypeError: coercing to Unicode: need string or buffer, file found
但我收到了错误
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#define N 100
int main (int argc, char *argv[]) {
int nthreads, tid, i;
float a[N], b[N], c[N];
/* Some initializations */
for (i=0; i < N; i++)
a[i] = b[i] = i;
#pragma omp parallel shared(a,b,c,nthreads) private(i,tid)
{
tid = omp_get_thread_num();
if (tid == 0)
{
nthreads = omp_get_num_threads();
printf("Number of threads = %d\n", nthreads);
}
printf("Thread %d starting...\n",tid);
#pragma omp for
for (i=0; i<N; i++)
{
c[i] = a[i] + b[i];
printf("Thread %d: c[%d]= %f\n",tid,i,c[i]);
}
} /* end of parallel section */
}
答案 0 :(得分:0)
您正在此行中打开文件
self.f = open('data.txt', 'r')
并尝试打开文件句柄而不是此行中的同一文件
with open(self.f) as f:
相反,在nextTuple
中,只需使用self.f
代替f