from py_mini_racer import MiniRacer
withopen(r"./demo.js", encoding="utf-8")as f:
ctx =MiniRacer()
ctx.eval(f.read())print(ctx.call('get_m',5,6))
3. NodeVM
Install:pip install node_vm2
Guide package:from node_vm2 import NodeVM
Call method 1 is as follows: call js file
from node_vm2 import NodeVM
withopen(r"./demo.js", encoding="utf-8")as f:
ctx = NodeVM.code(f.read())print(ctx.call_member("get_m",5,6))
The calling method 2 is as follows: use eval
from node_vm2 importevalprint(eval("cookie='Hm_lvt_444ece9ccd5b847838a56c93a0975a8b=1636208098'"))
Changed the computer environment and suddenly reported an error: TypeError: write() argument must be str, not bytes, the first step is to remove line 488.encode("utf-8")
Then run and then report an error 'str' object has no attribute 'decode', then remove the line 395 as follows .decode("utf-8"), and then it will be normal