gpt4 book ai didi

python - pliSTLib 无法读取 Safari 的 plist 文件

转载 作者:太空狗 更新时间:2023-10-30 01:51:19 24 4
gpt4 key购买 nike

<分区>

我正在尝试使用 python 修改 plist 文件。我将一个 plist 从我的库复制到我的桌面以安全地使用它。我导入了 ospliSTLib。我正在关注我在 documentation here 中看到的内容.

import plistlib
import os

test_prefs = "~/Desktop/com.apple.Safari.plist"

x = readPlist(os.path.expanduser(test_prefs))
print x["TopSitesGridArrangement"]

但这失败了。我做错了什么?

我得到的确切错误:

Traceback (most recent call last):
File "/Users/Josh/Desktop/destroy.py", line 11, in <module>
x = readPlist(os.path.expanduser(test_prefs))
NameError: name 'readPlist' is not defined

当我将其更改为 x = pliSTLib.readPlist(os.path.expanduser(test_prefs)) 时,我得到的错误如下(我的文件名为 destroy.py):

Traceback (most recent call last):
File "/Users/Josh/Desktop/destroy.py", line 11, in <module>
x = plistlib.readPlist(os.path.expanduser(test_prefs))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 78, in readPlist
rootObject = p.parse(pathOrFile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 406, in parse
parser.ParseFile(fileobj)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 8

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com