#file handling in python
#create a new file and perform read,write operaion
str1="this is a test string"
file=open("NewFile.txt","w")#open file in write mode
txt=file.write(str1)#this will overwrite the file
file.close()#close file after operation
file1=open("NewFile.txt","r")#open file in read mode
txt2=file1.read()
file1.close()
print ("content of file:-")
print(txt2)
No comments:
Post a Comment