栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python使用execjs执行js、传入参数时出现UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0x80 in position

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python使用execjs执行js、传入参数时出现UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0x80 in position

报错:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "D:learnpythonlibthreading.py", line 926, in _bootstrap_inner
    self.run()
  File "D:learnpythonlibthreading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "D:learnpythonlibsubprocess.py", line 1269, in _readerthread
    buffer.append(fh.read())
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 10: illegal multibyte sequence

Traceback (most recent call last):
  File "E:/爬虫爬虫/爬虫项目/书旗小说/解密.py", line 14, in 
    get_data()
  File "E:/爬虫爬虫/爬虫项目/书旗小说/解密.py", line 10, in get_data
    data = return_js.call('_decodeCont',t)  # 传入参数t进入函数_decondeCont中
  File "D:learnpythonlibsite-packagesexecjs_abstract_runtime_context.py", line 37, in call
    return self._call(name, *args)
  File "D:learnpythonlibsite-packagesexecjs_external_runtime.py", line 92, in _call
    return self._eval("{identifier}.apply(this, {args})".format(identifier=identifier, args=args))
  File "D:learnpythonlibsite-packagesexecjs_external_runtime.py", line 78, in _eval
    return self.exec_(code)
  File "D:learnpythonlibsite-packagesexecjs_abstract_runtime_context.py", line 18, in exec_
    return self._exec_(source)
  File "D:learnpythonlibsite-packagesexecjs_external_runtime.py", line 87, in _exec_
    output = self._exec_with_pipe(source)
  File "D:learnpythonlibsite-packagesexecjs_external_runtime.py", line 103, in _exec_with_pipe
    stdoutdata, stderrdata = p.communicate(input=input)
  File "D:learnpythonlibsubprocess.py", line 966, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "D:learnpythonlibsubprocess.py", line 1319, in _communicate
    stdout = stdout[0]
IndexError: list index out of range

解决方法:修改编码文件的默认编码格式为utf-8(默认为gbk)

点击进入并修改:

 将encoding修改前一定一定一定要备份!!!!到时候改错了可以再改回来

最后运行就成功了

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/846557.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号