1 #读取图片并存储为矩阵 2 from scipy.misc import imread 3 im = imread("/Users/NaCl/Documents/GitHub/test.png") 4 5 #将读取到的矩阵数据序列化、即进行持久性存储 6 from numpy import * 7 import pickle 8 9 with open('test.pickle', 'wb') as f: 10 pickle.dump(im, f) 11 12 #将数据进行反序列化 13 with open('/Users/NaCl/Documents/GitHub/test.pickle', 'rb') as f: 14 f = pickle.load(f) 15 print type(f) 16 print f.shape 17