可以自动更新plist
文件中特定字段的脚本。我想更新plist
中的具体值。
我想改变“颜色”值。在python 3.5中怎么可能?
示例:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AlarmFilter</key>
<true/>
<key>AlarmsDisabled</key>
<false/>
<key>AttachmentFilter</key>
<true/>
<key>AutoRefresh</key>
<true/>
<key>Checked</key>
<integer>1</integer>
<key>Color</key>
<string>#808000FF</string>
</dict>
</plist>
我写了这段代码:
import plistlib
answer = plistlib.readPlist('plist_path')
ans = dict.values(answer)
ans1 = dict.keys(answer)
que = input('Enter Element Name:- \n')
try:
p = answer[que] = "ravi"
plistlib.writePlist(p, answer)
except:
print("Failure")