read()-
- read() is a python file function which are used to read the existing file.
Syntax-
f.read()
-Here 'f' is the object which points the existing file.
write()-
- write() is a python file function which are used to write in the file.
- If the file is not exist then write() function create new file.
Syntax-
f.write(string)
-Here string is the content which we want to insert into the file.
program-
#opne file in write mode
f=open("myfile.txt",'w')
f.write("Data insert into the file")
f.close()
#open file in read mode
f=open("myfile.txt",'r')
data=f.read()
print(data)
print(type(data))
f.close()
Data insert into the file