It looks like you might have defined a variable named file
which is a string. Python then complains that str
objects are not callable when it encounters
file(...)
You can avoid the issue by, as Bitwise says, changing file
to open
.
You could also avoid the problem by not naming a variable file
.
Nowadays, the best way to open a file is by using a with
-statement:
with open(outfile+'.x.betas','a') as f_handle:
np.savetxt(f_handle,dataPoint)
This guarantees that the file is closed when Python leaves the with
-suite.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…