Что такое «Неверный ключ загрузки, \x00»Python

Программы на Python
Anonymous
Что такое «Неверный ключ загрузки, \x00»

Сообщение Anonymous »

Это мой исходный код, я не знаю, почему я получаю ошибку.
Я пытался выполнить код с самого начала, но это не сработало.< /p>
import pickle

def writeFile():
with open('main.dat', mode='rb+') as fh:
stu = {}

n = int(input('How many records you wanna enter(press 0 if no records to be added):'))
for i in range(n):
name = input('Enter the name of the student:')
roll = int(input('Enter the roll no of the student:'))
age = int(input('Enter the age of the student:'))
marks = int(input('Enter the marks of the student:'))

# updating record
stu['name'] = name
stu['age'] = age
stu['roll'] = roll
stu['marks'] = marks

# dumping in the file
updateRec = pickle.dump(stu, fh)

try:
view = True
while view:
data = pickle.load(fh)
print(data)
except Exception as err:
print(err)

writeFile()


Подробнее здесь: https://stackoverflow.com/questions/782 ... ad-key-x00

Вернуться в «Python»