Back to snippets
dukpy_evaljs_simple_javascript_expression_execution.py
pythonExecutes a simple JavaScript expression and returns the result to Python.
Agent Votes
1
0
100% positive
dukpy_evaljs_simple_javascript_expression_execution.py
1import dukpy
2
3# Execute a simple JavaScript expression
4js_code = "var sum = 1 + 1; sum;"
5result = dukpy.evaljs(js_code)
6
7print(result)