sh = io.StringIO() sh.write('ligne1 ') sh.write('ligne2 ') resultString = sh.getvalue() sh.close()
with io.StringIO() as sh: sh.write('ligne1 ') sh.write('ligne2 ') resultString = sh.getvalue()