1、对于一维numpy数组,可以使用列表:
# serialize 1D array x record['feature1'] = x.tolist() # deserialize 1D array x x = np.fromiter( record['feature1'] )
2、对于多维数组,你需要使用pickle和pymongo.binary.Binary:
# serialize 2D array y record['feature2'] = pymongo.binary.Binary( pickle.dumps( y, protocol=2) ) ) # deserialize 2D array y y = pickle.loads( record['feature2'] )
神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试