import io for e in sorted(dir(io), key=lambda s: s.lower()): print(e)
__all__ | |
__author__ | |
__builtins__ | |
__cached__ | |
__doc__ | |
__file__ | |
__getattr__ | |
__loader__ | |
__name__ | |
__package__ | |
__spec__ | |
_io | |
_WindowsConsoleIO | |
abc | |
BlockingIOError | |
BufferedIOBase | |
BufferedRandom | |
BufferedReader | |
BufferedRWPair | |
BufferedWriter | |
BytesIO | |
DEFAULT_BUFFER_SIZE | |
FileIO | |
IncrementalNewlineDecoder | |
IOBase | |
open | |
open_code | |
RawIOBase | |
SEEK_CUR | |
SEEK_END | |
SEEK_SET | |
StringIO | The StringIO class creates a «file-like» object from a string, which allows to read from it as if it were a file. Compare with csv.StringIO . |
text_encoding | |
TextIOBase | |
TextIOWrapper | |
UnsupportedOperation |
io
module. open
function. io
module, such an in-place modification can be simulated with StringIO()
: import io txt = 'Hello world!' txt_io = io.StringIO(txt) print(txt_io.getvalue()) txt_io.seek(6) txt_io.write('there') print(txt_io.getvalue())
io.open()
is the same function as the built-in function open()
. __file__
needs to be replaced with the filename to be read: with open (__file__, 'r') as f: text = f.read() print(text)