我已经在colab中上传了我的火车和测试文件。
from google.colab import files
uploaded = files.upload()
uploaded.keys()
with open(uploaded['train_qa.txt'], "rb") as fp:
train_data = pickle.load(fp.read())]
我收到以下错误:
ValueError Traceback (most recent call last)
<ipython-input-9-afaa1d381444> in <module>()
----> 1 with open(uploaded['train_qa.txt'], "rb") as fp:
2 train_data = fp.read()
ValueError: embedded null byte
我该如何解决?我只想读取colab中的文件。我知道其他解决方法,但是如何解决此错误?
最佳答案
上传的已经映射到字节。
所以:
train_data = pickle.load(uploaded['train_qa.txt'])
关于python - 如何读取存储为字典值之一的二进制文件数据?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55761901/