windows - Unicode解码错误: 'utf8' codec can't decode byte 0x92 in position 377826: invalid start byte

标签 windows git github encoding utf-8

我在 if uID in repo.git.log(): 行执行下面的代码片段时出现以下错误, 问题出在 repo.git.log() 中,我查看了 Stack Overflow 上的所有类似问题,建议使用 decode("utf-8")

如何将 repo.git.log() 转换为 decode("utf-8")

UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position 377826: invalid start byte 

相关代码:

..................
uID = gerritInfo['id'].decode("utf-8")                                            
if uID in repo.git.log():
        inwslist.append(gerritpatch)      
.....................


Traceback (most recent call last):
  File "/prj/host_script/script.py", line 1417, in <module>
    result=main()
  File "/prj/host_script/script.py", line 1028, in main
    if uID in repo.git.log():
  File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 431, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 802, in _call_process
    return self.execute(make_call(), **_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 610, in execute
    stdout_value = stdout_value.decode(defenc)
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position 377826: invalid start byte

最佳答案

使用 encoding='cp1252' 将解决问题。

关于windows - Unicode解码错误: 'utf8' codec can't decode byte 0x92 in position 377826: invalid start byte,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29419322/

相关文章:

windows - 使用命令行/批处理切换到/专注于应用程序

c++ - 如何正确模拟服务中的用户?

Git 网址与 http 网址

Github 操作仅在功能分支上运行

github - Azupre Pipelines + Github + 无法为拉取请求创建检查

windows - FFMPEG 输出到 DeckLink Duo 2

c++ - 如何 CloseHandle 转换为 FILE* 的句柄?

git - 如何 merge 提交到某个点

GIT 分支 - 我们能在只有 master 的情况下生存吗?

git - 默认情况下如何使 git-pull 冗长?