pip install js2py
app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#import the necessary module! import js2py #example 1 #a JS command jsl = 'console.log("Hello World!")' resl = js2py.eval_js(jsl) #print the result #exapmle 2 #a JS function #take user input a = int(input('Enter a num: ')) js2 = '''function add(a, b){ return a + b; } ''' res2 = js2py.eval_js(js2) #print the result print(res2(a,3)) |