'utf-8' 编解码器无法解码 LZ4 上位置 12 中的字节 0xf0 和 Python 3.x
'utf-8' codec can't decode byte 0xf0 in position 12 on LZ4 and Python 3.x
我正在使用 lz4 和 JSON 从 firefox 目录解码 recovery.jsonlz4 文件。但是,我不断收到此错误。
Firefox 版本:69.0
#!/usr/bin/python3
import os, json, lz4.block
f = open("/home/<userName>/.mozilla/firefox/or9wxah0.default/sessionstore-backups/recovery.jsonlz4", "r")
magic = f.read(8)
jdata = json.loads(lz4.block.decompress(f.read()).decode("utf-8"))
f.close()
for win in jdata.get("windows"):
for tab in win.get("tabs"):
i = int(tab.get("index")) - 1
urls = tab.get("entries")[i].get("url")
print(urls)
错误:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 in position 12: invalid continuation byte
已解决:
忘记添加'rb'
f = open("/home/<userName>/.mozilla/firefox/or9wxah0.default/sessionstore-backups/recovery.jsonlz4", "rb")
我正在使用 lz4 和 JSON 从 firefox 目录解码 recovery.jsonlz4 文件。但是,我不断收到此错误。
Firefox 版本:69.0
#!/usr/bin/python3
import os, json, lz4.block
f = open("/home/<userName>/.mozilla/firefox/or9wxah0.default/sessionstore-backups/recovery.jsonlz4", "r")
magic = f.read(8)
jdata = json.loads(lz4.block.decompress(f.read()).decode("utf-8"))
f.close()
for win in jdata.get("windows"):
for tab in win.get("tabs"):
i = int(tab.get("index")) - 1
urls = tab.get("entries")[i].get("url")
print(urls)
错误:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 in position 12: invalid continuation byte
已解决:
忘记添加'rb'
f = open("/home/<userName>/.mozilla/firefox/or9wxah0.default/sessionstore-backups/recovery.jsonlz4", "rb")