小编Rya*_*yan的帖子

带有 readPlist 和 AttributeError 的 DeprecationWarning

我正在尝试找到一种访问 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'])
Run Code Online (Sandbox Code Playgroud)

我不断得到结果,但也会出现一些快速错误。我得到这个:

plist.py:8: DeprecationWarning: The readPlist function is deprecated, use load() instead pl=plistlib.readPlist(fileName)
Run Code Online (Sandbox Code Playgroud)

还有这个:

  File "plist.py", line 16, in <module>
    for values in right.values():
   AttributeError: 'bool' object has no attribute 'values'
Run Code Online (Sandbox Code Playgroud)

我猜使用加载函数相当简单,尽管我很难使用我在网上找到的教程来弄清楚它并根据我的需要进行修改。

关于布尔属性错误,我不知道我做错了什么。

谢谢!

python boolean plist attributeerror

5
推荐指数
1
解决办法
5894
查看次数

标签 统计

attributeerror ×1

boolean ×1

plist ×1

python ×1