[go: up one dir, main page]

0% found this document useful (0 votes)
11 views2 pages

Myfile

Uploaded by

annavarshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Myfile

Uploaded by

annavarshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#import os

#cwd=os.getcwd()
#print(cwd)

#program to write structure, list in binary file


#def foperation():
# import pickle
# list1=[10,20,30,40,100]
# f=open('list.dat','wb')
# pickle.dump(list1,f)
# print("list added to binary file")
# f.close()

#foperation()

#program to write structure, dictionary in binary file


#import pickle
#dict1={'python':90,'java':98,'c++':87}
#f=open('bin_file.dat','wb')
#pickle.dump(dict1,f)
#f.close()

#program to read file


#import pickle
#f=open('bin_file.dat','rb')
#dict1=pickle.load(f)
#f.close()
#print(dict1)

#program to store multiple integer in binary file and read


"""def binfile():
import pickle
file=open('data.dat','wb')
while True:
x=int(input("enter the integer:"))
pickle.dump(x,file)
ans=input('do you want to enter more data Y/N:')
if ans.upper()=='N': break
file.close()
file=open('data.dat','rb')
try:
while True:
y=pickle.load(file)
print(y)
except EOFError:
pass
binfile()"""
#program for inserting/appending a record in a binary file-
"""import pickle
record=[]
while True:
roll_no=int(input("Enter student roll no:"))
name=input("Enter the student name:")
marks=int(input("Enter the marks obtained:"))
data=[roll_no,name,marks]
record.append(data)
choice=input("wish to enter more records (Y/N)?:")
if choice.upper()=='N':
break
f=open("student","wb")
pickle.dump(record, f)
print("record added")
f.close()"""

You might also like