Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 带有readPlist&;的弃用警告;属性错误_Python_Boolean_Plist_Attributeerror - Fatal编程技术网

Python 带有readPlist&;的弃用警告;属性错误

Python 带有readPlist&;的弃用警告;属性错误,python,boolean,plist,attributeerror,Python,Boolean,Plist,Attributeerror,我正在试图找到访问plist文件的方法:/Library/Preferences/com.apple.iPod.plist以访问其中的序列号 这是我目前的代码-- 我不断得到结果,但也会出现一些快速错误。我得到这个: plist.py:8: DeprecationWarning: The readPlist function is deprecated, use load() instead pl=plistlib.readPlist(fileName) File "plist.py",

我正在试图找到访问plist文件的方法:/Library/Preferences/com.apple.iPod.plist以访问其中的序列号

这是我目前的代码--

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

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'
还有这个:

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'
文件“plist.py”,第16行,在
对于right.values()中的值:
AttributeError:“bool”对象没有属性“值”
我猜使用load函数是相当简单的,尽管我在网上找到了一些教程,并根据自己的需要对其进行了修改,但我还是很难理解

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


谢谢

若要消除弃用错误,请将包含
readPlist
的行替换为

with open(fileName, 'rb') as f:
    pl = plistlib.load(f)
您的第二个问题似乎是由于以下方面的变化:

在版本3.7中更改:结果中的Dict值现在是正常Dict。您不再可以使用属性访问来访问这些词典的项

我遇到了一个类似的问题:
AttributeError:“dict”对象没有属性“children”
通过将
someObj.children[:]
替换为
someObj['children']
来解决。我想您对
right.values()
的调用可能会出现类似的情况,但如果没有您所期望的plist的实际示例,就很难判断