python - What's the difference between opening a file for update and just appending? -


as in, when opening file open(), why have modes 'r+', 'w+', 'a+'? surely mode 'a' same job? i'm confused difference between modes 'a' , 'a+' - explain differ and, if possible, when 1 should use 1 or other?

the opening modes same c fopen() std library function.

the bsd fopen manpage defines them follows:

 ``a''   open writing.  file created if not exist.           stream positioned @ end of file.  subsequent writes          file end @ current end of file,          irrespective of intervening fseek(3) or similar.   ``a+''  open reading , writing.  file created if not          exist.  stream positioned @ end of file.  subse-          quent writes file end @ current          end of file, irrespective of intervening fseek(3) or similar. 

the difference between , a+ a+ allows reading of files.

see this post more info.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -