13 lines
340 B
Python
13 lines
340 B
Python
import subprocess
|
|
import re
|
|
|
|
|
|
def execute_python_code(code_block):
|
|
try:
|
|
result = subprocess.run(['python', '-c', code_block],
|
|
capture_output=True, text=True, timeout=5)
|
|
return result.stdout or result.stderr
|
|
except Exception as e:
|
|
return f"Execution error: {str(e)}"
|
|
|
|
|