Hi,
To read a file’s contents, call f.read(size)
, which reads some quantity of
data and returns it as a string (in text mode) or bytes object (in binary mode).
size is an optional numeric argument. When size is omitted or negative, the
entire contents of the file will be read and returned [...]. Otherwise, at most size bytes
are read and returned.
The problem is that it says "bytes", but in text mode, f.read(size)
will return size characters. It seems like this just wasn't updated since Python 2.
It could be rephrased as:
Otherwise, at most size characters (in text mode) or
size
bytes (in binary mode)
are read and returned.
Thanks,
William Andrea