Spaces:
Sleeping
Sleeping
File size: 315 Bytes
b8b9cbf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import sys
from io import StringIO
def execute_code(code: str):
try:
old_stdout = sys.stdout
redirected_output = sys.stdout = StringIO()
exec(code, globals())
sys.stdout = old_stdout
return redirected_output.getvalue()
except Exception as e:
return str(e)
|