Python gets the value in javascript
Copy codeThe Code is 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 retrieves values in python
Copy codeThe Code is 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 functions in javascriptPython calls func to use the function functions in js.
Copy codeThe Code is as follows:
Import PyV8
With PyV8.JSContext () as ctxt:
Func = ctxt. eval ("""
(Function ()
{
Function ()
{
Return "abc ";
}
Return ();
})
""")
Print func ()
You can also
Copy codeThe Code is as follows:
Import PyV8
With PyV8.JSContext () as ctxt:
Func = ctxt. eval ("""
Function ()
{
Return "abc ";
}
Function c ()
{
Return "abc ";
}
""")
A = ctxt. locals.
Print ()