issues
- encoding error
import subprocess
from functools import partial
subprocess.Popen = partial(subprocess.Popen, encoding="utf-8")
- module not found:
解决办法:指定node_modules所在目录
js = execjs.compile(
open(path.join(BASE_PATH, "tools/xxx.js"), "r", encoding="utf-8").read(),
cwd=path.join(BASE_PATH, "tools/node_modules")
)
- 获取Promise结果
abs_path = path.join(BASE_PATH, "js/manifest.js")
process = subprocess.Popen(["node", abs_path, data], stdout=subprocess.PIPE)
output, error = process.communicate()
clean_res = output.decode('utf-8').strip()
print(clean_res)
网友评论