In [1]:
from io import StringIO
In [2]:
s = (
'''hello
world
''')
s
Out[2]:
In [3]:
f = StringIO(s)
f
Out[3]:
In [4]:
for line in f:
print(repr(line))
In [5]:
with StringIO(s) as f:
for line in f:
print(repr(line))