我正在尝试使用Python操作Chrome书签文件,但是在第一个障碍时已经陷入困境。我有这段代码:
import json
import os
input_filename = os.getenv("APPDATA") + "\..\Local\Google\Chrome\User Data\Default\history"
with open(input_filename) as data_file:
bookmark_data = json.load(data_file)
当我运行此代码时,我收到以下错误:
Traceback (most recent call last):
File "C:/Users/David/PycharmProjects/MyBookmarks/myBookmarks.py", line 17, in <module>
bookmark_data = json.load(data_file)
File "C:\Python27\lib\json\__init__.py", line 290, in load
**kw)
File "C:\Python27\lib\json\__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "C:\Python27\lib\json\decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Python27\lib\json\decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Process finished with exit code 1
我对JSON并不熟悉,但鉴于这是Chrome书签文件,我怀疑这是文件结构的问题,我很难接受下一步的尝试!有什么想法吗?
提前致谢。
答案 0 :(得分:0)
JSON
文件的名称