BytesIO([buffer]) -> object
Create a buffered I/O implementation using an in-memory bytes buffer, ready for reading and writing.
Methods
close(() -> None. Disable all I/O operations.) | |
detach | Disconnect this buffer from its underlying raw stream and return it. |
fileno | Returns underlying file descriptor if one exists. |
flush(() -> None. Does nothing.) | |
getvalue(() -> bytes.) | Retrieve the entire contents of the BytesIO object. |
isatty(() -> False.) | Always returns False since BytesIO objects are not connected to a tty-like device. |
next | x.next() -> the next value, or raise StopIteration |
read(([size]) -> read at most size bytes, ...) | If the size argument is negative, read until EOF is reached. |
read1((size) -> read at most size bytes, ...) | If the size argument is negative or omitted, read until EOF is reached. |
readable(...) | |
readinto(...) | Returns number of bytes read (0 for EOF), or None if the object is set not to block as has no data to read. |
readline(...) | Retain newline. |
readlines(([size]) -> list of strings, ...) | Call readline() repeatedly and return a list of the lines so read. |
seek((pos[, whence]) | Seek to byte offset pos relative to position indicated by whence: 0 Start of stream (the default). |
seekable(...) | |
tell(() -> current file position, an integer) | |
truncate(...) | Size defaults to the current file position, as returned by tell(). |
writable(...) | |
write((bytes) -> int. Write bytes to file.) | Return the number of bytes written. |
writelines(...) | Note that newlines are not added. |
True if the file is closed.
Retrieve the entire contents of the BytesIO object.
Always returns False since BytesIO objects are not connected to a tty-like device.
x.next() -> the next value, or raise StopIteration
If the size argument is negative, read until EOF is reached. Return an empty string at EOF.
If the size argument is negative or omitted, read until EOF is reached. Return an empty string at EOF.
Returns number of bytes read (0 for EOF), or None if the object is set not to block as has no data to read.
Retain newline. A non-negative size argument limits the maximum number of bytes to return (an incomplete line may be returned then). Return an empty string at EOF.
Call readline() repeatedly and return a list of the lines so read. The optional size argument, if given, is an approximate bound on the total number of bytes in the lines returned.
Returns the new absolute position.
Size defaults to the current file position, as returned by tell(). The current file position is unchanged. Returns the new size.
Return the number of bytes written.
Note that newlines are not added. The sequence can be any iterable object producing strings. This is equivalent to calling write() for each string.