Python Gets the value in JavaScript
Copy Code code as follows:
Import PyV8
With Pyv8.jscontext () as ENV1:
Env1.eval ("" "
Var_i = 1;
Var_f = 1.0;
var_s = "Test";
Var_b = true;
""")
VARs = Env1.locals
Var_i = Vars.var_i
Print Var_i
JavaScript gets the value inside python
Copy Code code as follows:
Import PyV8
With Pyv8.jscontext () as ENV1:
Env1.securitytoken = "Foo"
Env1.locals.prop = 3
print int (env1.eval ("prop"))
function interaction in Python and JavaScript
Python calls the functions in JavaScript Python calls Func can use the function functions in JS
Copy Code code as follows:
Import PyV8
with Pyv8.jscontext () as Ctxt:
func = Ctxt.eval (""
(function ()
{
function A ()
{
return "ABC";
}
return a ();
})
""")
Print func ()
That's OK.
Copy Code code as follows:
Import PyV8
with Pyv8.jscontext () as Ctxt:
func = Ctxt.eval (""
function A ()
{
return "ABC";
}
Function C ()
{
Return "ABC";
}
""")
A = CTXT.LOCALS.A
Print a ()