Lew Pitcher於 2018年2月23日星期五 UTC+8上午9時43分19秒寫道: > jf...@ms4.hinet.net wrote: > > > ast於 2018年2月22日星期四 UTC+8下午8時33分00秒寫道: > >> Hello > >> > >> I share a very valuable table I found on > >> StackOverflow about file opening modes > >> > >> If like me you always forget the details of > >> file opening mode, the following table provides > >> a good summary > >> > >> | r r+ w w+ a a+ > >> ------------------|-------------------------- > >> read | + + + + > >> write | + + + + + > >> write after seek | + + + > >> create | + + + + > >> truncate | + + > >> position at start | + + + + > >> position at end | + + > > > > What the "write after seek" means? > > It /should/ mean that programs are permitted to seek to a point in the file, > and then write from that point on. > > A write to a read mode ("r") file isn't permitted at all, > so neither is "write after seek" to a read mode file. > > A write to an append mode ("a" and "a+") file always write to the end of the > file, effectively negating any seek. > > HTH > > -- > Lew Pitcher > "In Skills, We Trust" > PGP public key available upon request
Thank you for explanation. Mode 'r+', 'a' and 'a+' all can be seek and write, but only 'r+' was marked in the table. That's why I was confused. This row seems redundant to me:-) --Jach -- https://mail.python.org/mailman/listinfo/python-list