numpy 与 base64 相互转换

创建日期: 2023-03-01 15:37 | 作者: 风波 | 浏览次数: 13 | 分类: Python

来源:https://stackoverflow.com/questions/6485790/numpy-array-to-base64-and-back-to-numpy-array-python

import base64
import numpy as np

t = np.arange(25, dtype=np.float64)
s = base64.b64encode(t)
r = base64.decodebytes(s)
q = np.frombuffer(r, dtype=np.float64)

print(np.allclose(q, t))
# True
13 浏览
8 爬虫
0 评论