import execjs
with open('xx.js', 'r', encoding='gbk',errors='ignore') as f:
js_text = f.read()
ctx = execjs.compile(js_text)
text='dfsd'
result = ctx.call('xx_text', text)
print(result)
这样的,老是报错,encoding你改啥都不管事,gbk,utf-8,ascii,gbxxx....都没用,最后找到解决办法是https://blog.csdn.net/suwenlai/article/details/93047182
,当时的确是提示 subprocess.py处报的错,记得注释,以后好改回来[ 可以import subprocess文件改..]