i want to know the difference between 'r' mode and 'r+' mode
1.i = open('c:\python25\integer.txt','w')-------->for writiing
 i.write('hai')--------->written some content in text file
 i = open('c:\python25\integer.txt','r')---->for reading
 print i.read()---->for printing the contents in that text file
 i = open('c:\python25\integer.txt','w')---------->for writing
 i.write('how')-----------?Rewrite the contents
 print i.read()
[MY QUESTION]:i want to read the text file contents cant it be done by
giving (print i.read())?
Before going to next question [I deleted all the contents in the text file]

2.i = open('c:\python25\integer.txt','r+')-----For reading and writing
  i.write('hai')--------->written some content  to text file
  print i.read()--------->{؆('c:\python25\integer.txt','w')
                              i write('')
                              print i.read()how')
                              i = open('c:\python25\integer.txt','r')
                              print i.read()
                              i = open('c:\python25\integer.txt','w')
                              i.write()
                              i = open('c:\python25\integer.txt','r')
                             print i.read() } --->Thats what i saw on
interpreter(In curly braces) when  i ran the script
[MY QUESTION]:1.from where the above in curly braces is printed?and i have
written only 'hai' to the text file
                         2.Should i recall again the opening of the file in
'r' mode to read the file?

--

                                          Vanam
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to