[3.11] gh-101992: update plistlib examples to be runnable (GH-101994) by miss-islington · Pull Request #102000 · python/cpython
Generating a plist::
import datetime import plistlib
pl = dict( aString = "Doodah", aList = ["A", "B", 12, 32.1, [1, 2, 3]],
Parsing a plist::
with open(fileName, 'rb') as fp: pl = load(fp) print(pl["aKey"]) import plistlib
plist = b"""<plist version="1.0"> <dict> <key>foo</key> <string>bar</string> </dict> </plist>""" pl = plistlib.loads(plist) print(pl["foo"])