import numpy as np def mem2npy(memfile): # ...... # np.save(mynpyfile) if __name__ == '__main__': mem2npy(memfile='outputresult.mem')