json.load, JSONDecodeError: Expecting value: line 1 column 1 (char 0)
json.load, JSONDecodeError: Expecting value: line 1 column 1 (char 0)
我正在阅读 json.bz2 文件。
代码
with open(full_filename, 'r', encoding='utf-8', errors='ignore') as the_file:
data = json.load(the_file)
JSONDecodeError:预期值:第 1 行第 1 列(字符 0)
我尝试在 google 上搜索解决方案,但 none 有效。
您正在尝试直接解码压缩的 JSON。您需要先解压缩它。使用bz2 package。例如:
import json
import bz2
# ...
data = json.loads(bz2.BZ2File(full_filename).read().decode())
我正在阅读 json.bz2 文件。
代码
with open(full_filename, 'r', encoding='utf-8', errors='ignore') as the_file:
data = json.load(the_file)
JSONDecodeError:预期值:第 1 行第 1 列(字符 0)
我尝试在 google 上搜索解决方案,但 none 有效。
您正在尝试直接解码压缩的 JSON。您需要先解压缩它。使用bz2 package。例如:
import json
import bz2
# ...
data = json.loads(bz2.BZ2File(full_filename).read().decode())