Search
 
SCRIPT & CODE EXAMPLE
 

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())
Comment

PREVIOUS NEXT
Code Example
Python :: argparse parse path 
Python :: Power Crisis 
Python :: change a coolumn datatype in pandas 
Python :: python bot ban script 
Python :: python - subtracting dictionary values 
Python :: python toupper 
Python :: how to create tupple in python 
Python :: channel unhiding command in discord.py 
Python :: python := 
Python :: matplotlib yaxis off 
Python :: find in python 
Python :: get first not null value from column dataframe 
Python :: bag of word scikit learn 
Python :: input a number and print even numbers up to that number 
Python :: python add new key to dictionary 
Python :: get dummies pandas 
Python :: Removing Elements from Python Dictionary Using del keyword 
Python :: how to install python packages in local directory 
Python :: export list to a file python 
Python :: float error python 
Python :: convert to lwercase in df column 
Python :: normal discord.py codes 
Python :: odoo manifest 
Python :: request.args.get check if defined 
Python :: add element to array list python 
Python :: get element from string with deliminator python 
Python :: Swap 2 items of a list in python 
Python :: plot circles in matplotlib 
Python :: python linear interpolation 
Python :: python running mean pandas 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =