python-lmdb使用log

it2022-05-05  132

1
with open(imagePath, 'r') as f: imageBin = f.read()

错误:

imageBin = f.read() UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 0: illegal multibyte sequence

解决方法: open文件时按字节打开,参数加入 ‘b’

with open(imagePath, 'rb') as f: imageBin = f.read()
2写入的信息都需要编码为二进制形式
imageKey = ('image- d' % cnt).encode() labelKey = ('label- d' % cnt).encode() cache[imageKey] = imageBin cache[labelKey] = label.encode()

转载于:https://www.cnblogs.com/yeran/p/11202041.html

相关资源:各显卡算力对照表!

最新回复(0)