Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

save standard output in variable python

from io import StringIO
import sys

# get standard output
tmp = sys.stdout
my_result = StringIO()
sys.stdout = my_result
print('hello world') # output stored in my_result
sys.stdout = tmp

print(result.getvalue())
 
PREVIOUS NEXT
Tagged: #save #standard #output #variable #python
ADD COMMENT
Topic
Name
3+5 =