【发布时间】:2018-09-05 03:20:22
【问题描述】:
我正在尝试找到一种方法来访问 plist 文件:/Library/Preferences/com.apple.iPod.plist 以访问其中的序列号。
这是我当前的代码--
import os
import plistlib
fileName=os.path.expanduser('/Users/Ryan/Library/Preferences/com.apple.iPod.plist')
pl=plistlib.readPlist(fileName)
for left, right in pl.items():
for values in right.values():
print(values['Serial Number'])
我不断得到结果,但也出现了一些快速错误。我得到了这个:
plist.py:8: DeprecationWarning: The readPlist function is deprecated, use load() instead pl=plistlib.readPlist(fileName)
还有这个:
File "plist.py", line 16, in <module>
for values in right.values():
AttributeError: 'bool' object has no attribute 'values'
我猜想使用 load 函数相当简单,虽然我很难使用网上找到的教程来修改它以满足我的需要。
关于布尔属性错误,我不知道我做错了什么。
谢谢!
【问题讨论】:
标签: python boolean plist attributeerror