Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

get output of a function in a 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: #output #function #variable #python
ADD COMMENT
Topic
Name
4+6 =