python - a simple command -- "np.save", maybe i misunderstood -
just working through example numpy.save -- http://docs.scipy.org/doc/numpy/reference/generated/numpy.save.html
examples
from tempfile import temporaryfile outfile = temporaryfile() x = np.arange(10) np.save(outfile, x)
after command (highlighted), why not find output file called "outfile" in current directory? sorry may sound stupid
outfile.seek(0) # needed here simulate closing & reopening file np.load(outfile) array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
it because using - temporaryfile
, temporary file not stored outfile
in directory.
if want save outfile
, can give name , save file.
np.save('outfile',x)
when saving load, need use , again filename string -
np.load('outfile')
Comments
Post a Comment