-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathexecutor.py
22 lines (11 loc) · 1.31 KB
/
executor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import sys
import subprocess
def execute_python_code(code):
result = subprocess.run(['python3', '-c', code], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
return result.stdout, result.stderr
if __name__ == '__main__':
code = sys.argv[1]
stdout, stderr = execute_python_code(code)
print(stdout)
if stderr:
sys.stderr.write(stderr)