About python's pickle module

the program in this link (View paste IODA) raises unpickling error when I pass specific data… I have also attached another set of input which also raises this error. I just know how to resolve this error using truncate() function. But I wanna know why this error is raised…

Scenario 2:
Enter number of records: 2
Enter roll no: 1
Enter name: er
Enter class: 12
Enter roll no: 2
Enter name: er
Enter class: 12
[1, ‘er’, ‘12’]
[2, ‘er’, ‘12’]
Enter roll.no to search: 1
Enter name to update: dtghtfh
Traceback (most recent call last):
File “/home/rvd/Projects/POCs/class.py”, line 42, in
check()
File “/home/rvd/Projects/POCs/class.py”, line 21, in check
data = pickle.load(fo)
^^^^^^^^^^^^^^^
_pickle.UnpicklingError: invalid load key, ‘\x00’.

Hello,

welcome to the Python forum.

Please enter your script per:

This way, it appears as it would on your terminal. Here is an example:

def some_function(arg1, arg2):

    print('Entered this function with no problem')

    return arg1 * arg2
1 Like