我是新来的。我试图加载重播,但收到以下错误。另外,我尝试了不同的重播文件,SC2可以播放它们。我的代码如下:

from sc2reader.factories import SC2Factory

path = 'D:/Code/Test/replays/LerilakCrest.SC2Replay'
sc2 = SC2Factory()
replay = sc2.load_replay(path)

print('done')

错误消息:
Traceback (most recent call last):
File "D:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.4\helpers\pydev\pydevd.py", line 2358, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "D:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.4\helpers\pydev\pydevd.py", line 1778, in run
pydev_imports.execfile(file, globals, locals)  # execute the script
File "D:/Code/Test/read.py", line 9, in <module>
replay = sc2.load_replay(path)
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\factories\sc2factory.py", line 85, in load_replay
return self.load(Replay, source, options, **new_options)
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\factories\sc2factory.py", line 137, in load
return self._load(cls, resource, filename=filename, options=options)
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\factories\sc2factory.py", line 146, in _load
obj = cls(resource, filename=filename, factory=self, **options)
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\resources.py", line 262, in __init__
self._read_data(data_file, self._get_reader(data_file))
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\resources.py", line 592, in _read_data
self.raw_data[data_file] = reader(data, self)
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\readers.py", line 33, in __call__
) for i in range(data.read_bits(5))],
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\decoders.py", line 252, in read_aligned_string
return self._buffer.read_string(count, encoding)
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\decoders.py", line 108, in read_string
return self.read_bytes(count).decode(encoding)
File "D:\Program Files (x86)\Python 2.7\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)

UnicodeDecodeError:“utf8”编码解码器无法解码位置0中的字节0xff:起始字节无效

最佳答案

乔伊,sc2reader的另一个用户!
我知道这个问题,这是因为你的版本比你的重播还旧。
个人而言,我已经解决了我的问题:

sudo pip install git+https://github.com/StoicLoofah/sc2reader@lotv#egg=sc2reader --upgrade

这是sc2reader的最新版本,它支持LotV。

关于python - sc2reader无法加载我的重播文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33740617/

10-09 19:33