diff --git a/1 File handle/File handle binary/Deleting record in a binary file.py b/1 File handle/File handle binary/Deleting record in a binary file.py index 41a5007b86c..d3922a5afc4 100644 --- a/1 File handle/File handle binary/Deleting record in a binary file.py +++ b/1 File handle/File handle binary/Deleting record in a binary file.py @@ -3,13 +3,13 @@ def bdelete(): # Opening a file & loading it - with open("studrec.dat") as F: + with open("studrec.dat","rb") as F: stud = pickle.load(F) print(stud) # Deleting the Roll no. entered by user rno = int(input("Enter the Roll no. to be deleted: ")) - with open("studrec.dat") as F: + with open("studrec.dat","wb") as F: rec = [i for i in stud if i[0] != rno] pickle.dump(rec, F) diff --git a/1 File handle/File handle binary/File handle binary read (record in non list form).py b/1 File handle/File handle binary/File handle binary read (record in non list form).py index f37d97f0bff..bb9f127ea0b 100644 --- a/1 File handle/File handle binary/File handle binary read (record in non list form).py +++ b/1 File handle/File handle binary/File handle binary read (record in non list form).py @@ -2,7 +2,7 @@ def binary_read(): - with open("studrec.dat") as b: + with open("studrec.dat","rb") as b: stud = pickle.load(b) print(stud)