0
如何使用此工作代碼:保存蟒蛇plistlib數據(修訂)
import plistlib, time
import zipfile
from contextlib import closing
import os
with closing(zipfile.ZipFile("fw.zip")) as zfile:
for info in zfile.infolist():
if info.filename.endswith('Restore.plist'):
zfile.extract(info)
import plistlib as pl
p=pl.readPlist("Restore.plist")
print p["ProductType"]
print p["ProductVersion"]
print p["ProductBuildVersion"]
outputfile = open('output.txt', 'w')
outputfile.write(p["ProductVersion"])
outputfile.write(' ')
outputfile.write(p["ProductType"])
outputfile.write(' ')
outputfile.write(p["ProductBuildVersion"])
outputfile.close()
,並用它在這個plist中的「更新」鍵寫出來的字符串,看到更新的關鍵是如何在另一個一組名爲「RestoreRamDisks」的按鍵?
<key>RestoreRamDisks</key>#this is the key that the "update" key is under
<dict>
<key>Update</key>#here is the update key I'm talking about
<string>018-7074-092.dmg</string>#this is what I want python to spit out
<key>User</key>
<string>018-7082-092.dmg</string>
</dict>
爲了澄清,我只是想用上面的同樣的方法來獲取「更新」鍵的信息。令我困惑的部分是「更新」鍵在另一個名爲「RestoreRamDisks」的鍵下。當要求定位「更新」鍵時,我希望此程序吐出018-7074-092.dmg ..
真棒!有效!!!!!!非常感謝sooooooooo! – user715578