Diff between opening files in 'r' and 'r+' mode

Ben Finney bignose+hates-spam at benfinney.id.au
Tue Jan 30 04:58:14 EST 2007


"raghu" <vgvr620034 at gmail.com> writes:

> 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]

This is amazingly hard to read. Can you please post your message
again, this time using ordinary whitespace (e.g. a blank line) to
separate program examples from other text.

All the punctuation characters you're using have typographical
meaning, and your arbitrary use of them for apparently decorative
purposes make it difficult to see what you're trying to day.

-- 
 \             "Experience is that marvelous thing that enables you to |
  `\      recognize a mistake when you make it again."  -- Franklin P. |
_o__)                                                            Jones |
Ben Finney




More information about the Python-list mailing list