MCPcopy Create free account
hub / github.com/geekcomputers/Python / update

Function update

1 File handle/File handle binary/Update a binary file2.py:6–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5
6def update():
7 with open("studrec.dat", "rb+") as File:
8 value = pickle.load(File)
9 found = False
10 roll = int(input("Enter the roll number of the record"))
11
12 for i in value:
13 if roll == i[0]:
14 print(f"current name {i[1]}")
15 print(f"current marks {i[2]}")
16 i[1] = input("Enter the new name")
17 i[2] = int(input("Enter the new marks"))
18 found = True
19
20 if not found:
21 print("Record not found")
22
23 else:
24 pickle.dump(value, File)
25 File.seek(0)
26 print(pickle.load(File))
27
28
29update()

Callers 1

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected