Skip to content

Commit 7f56c9a

Browse files
Merge pull request #2447 from 16ratneshkumar/master
add Mode
2 parents 916e47a + b8ff109 commit 7f56c9a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

1 File handle/File handle binary/Deleting record in a binary file.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
def bdelete():
55
# Opening a file & loading it
6-
with open("studrec.dat") as F:
6+
with open("studrec.dat","rb") as F:
77
stud = pickle.load(F)
88
print(stud)
99

1010
# Deleting the Roll no. entered by user
1111
rno = int(input("Enter the Roll no. to be deleted: "))
12-
with open("studrec.dat") as F:
12+
with open("studrec.dat","wb") as F:
1313
rec = [i for i in stud if i[0] != rno]
1414
pickle.dump(rec, F)
1515

1 File handle/File handle binary/File handle binary read (record in non list form).py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
def binary_read():
5-
with open("studrec.dat") as b:
5+
with open("studrec.dat","rb") as b:
66
stud = pickle.load(b)
77
print(stud)
88

0 commit comments

Comments
 (0)