December 2018
Beginner to intermediate
796 pages
19h 54m
English
The first will show you the io.StringIO class, which is an in-memory stream for text IO. The second one instead will escape the locality of our computer, and show you how to perform an HTTP request. Let's see the first example:
# io_examples/string_io.pyimport iostream = io.StringIO()stream.write('Learning Python Programming.\n')print('Become a Python ninja!', file=stream)contents = stream.getvalue()print(contents)stream.close()
In the preceding code snippet, we import the io module from the standard library. This is a very interesting module that features many tools related to streams and IO. One of them is StringIO, which is an in-memory buffer in which we're going to write two sentences, using two different methods, ...
Read now
Unlock full access