CS final project
CS final project
PROJECT FILE
Teacher’s Signature
INDEX
S. NO. CONTENTS
1 Introduction
Creating/ Opening/
2
Closing binary files
3 Functions
Updating records in a
4
file
Codes/ Programmes/
5
Outputs
6 Bibliography
INTRODUCTION
In a binary file, data is stored in a sequence of
bytes (8 bits), and these bytes can represent any
kind of data, such as images, audio, video,
executable programs, or even compressed data.
File Extension: .dat
Module: Pickle
Modes: rb, wb, ab
#Functions
Import pickle
import pickle
# Declare empty dictionary to hold the read
record.
Emp= {}
while True:
Emp= pickle.load(Empfile)
print(Emp)
except:
Empfile.close() # Close file
import pickle
Stu= {} # declare empty dictionary
import pickle
Stu= {}
Stu = pickle.load(Fin)
if Stu[‘Rollno’] in Searchkeys:
print (Stu)
else:
#print the record
print (“Records not found”)
Fin.close() # Close file
import pickle
Stu= {}
Fin= open(‘Stu.dat’, ‘rb+’)
#opening the file in the read as well as write mode
try:
While True:
Fin.seek(Rpos)
import pickle
String= eval(input(‘Enter the string:”))
with open (“Myfile.info”, ‘wb’) as f:
pickle.dump(String, f)
with open (“Myfile.info”, ‘rb’) as f:
St= “”
St= pickle.load(f)
Ist = St.split(‘o’)
print( Ist[0])
#Enter the string: “This is my first line. This is
second line.”
This is my first line. This is sec
Import pickle
Stu= {}
found= False
if Stu[‘Marks’] >81 :
print(Stu)