_pickle.UnpicklingError: could not find MARK appears when the file is loaded

When debugging the project code today, there was an error loading the file
_pickle.UnpicklingError: could not find MARK
insert image description here

When using pickle deserialization, it is necessary to pre-import the class of custom class data that exists in the binary data

The principle of pickle deserialization, deserialization should be the process of restoring binary data according to a template, so you should import custom types when serializing

Solution:

Error _pickle.UnpicklingError: could not find MARK```引发是因为文件的偏移量不在开头。解决方法是拨打f.seek(0)` before loading pickle.
insert image description here
Hope this works for you!

Guess you like

Origin blog.csdn.net/qq_44936246/article/details/121594103