https://docs.python.org/3/library/gzip.html
I am considering to use gzip.open()
, and I am a little confused about the mode
argument:
The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', 'wb', 'x' or 'xb' for binary mode, or 'rt', 'at', 'wt', or 'xt' for text mode. The default is 'rb'.
So what is the difference between 'w'
and 'wb'
?
The document states they are both binary mode.
So does that mean that there is no difference between 'w'
and 'wb'
?
It means that r
defaults to rb
, and if you want text you have to specify it using rt
.
(as opposed to open
behaviour where r
means rt
, not rb
)