execjs UnicodeEncodeError: 'gbk' codec can't encode character '\xff' in position 23995: illegal multibyte sequence

import subprocess

# 创建一个新的 Popen 类,并继承自 subprocess.Popen
class MySubprocessPopen(subprocess.Popen):
    def __init__(self, *args, **kwargs):
        # 在调用父类(即 subprocess.Popen)的构造方法时,将 encoding 参数直接置为 UTF-8 编码格式
        super().__init__(encoding='UTF-8', *args, **kwargs)


# 必须要在导入 PyExecJS 模块前,就将 subprocess.Popen 类重置为新的类
subprocess.Popen = MySubprocessPopen

# 导入 PyExecJS 模块
import execjs

# 在后面继续写程序具体的执行逻辑 ...

 

posted @ 2023-03-29 13:59  淋哥  阅读(185)  评论(0编辑  收藏  举报