File Handling - Worksheet - Set 4 - AK
File Handling - Worksheet - Set 4 - AK
fh=file("poem.txt","r")
size=len(fh.read())
print(fh.read(5))
fh.close()
Answer :
Ans. No output
13.Write a code to print just the last line of the file ‘poem.txt’.
Answer :
f1=open('poem.txt','r')
r=f1.readlines()
print(r[-1])
with open('ingredients.dat','rb') as f:
lst=pickle.load(f)
print(lst)
except EOFError:
if found=False:
print('no match found')
else:
print('record updated successfully')
f.close()
t.close()
os.remove('emp1.dat')
os.rename('temp','emp1.dat')
#calling function
search_details()