python, numpy
code:
objOutput = open(arguments_strOut, 'wb')
numpy.array([ 80, 73, 69, 72 ], numpy.uint8).tofile(objOutput)
numpy.array([ tenOutput.shape[2], tenOutput.shape[1] ], numpy.int32).tofile(objOutput)
numpy.array(tenOutput.numpy().transpose(1, 2, 0), numpy.float32).tofile(objOutput)
objOutput.close()
- 用python的open方法,定义一个写入文件
- 用numpy的tofile方法,写入到文件中
vscode中用hexdump可以进行文件检查
可以看到写入的第一个数是80