plistlib.load()

plistlib.load(fp, *, fmt=None, use_builtin_types=True, dict_type=dict)

Read a plist file. fp should be a readable and binary file object. Return the unpacked root object (which usually is a dictionary).

The fmt is the format of the file and the following values are valid:

  • None: Autodetect the file format
  • FMT_XML: XML file format
  • FMT_BINARY: Binary plist format

If use_builtin_types is true (the default) binary data will be returned as instances of bytes, otherwise it is returned as instances of Data.

The dict_type is the type used for dictionaries that are read from the plist file. The exact structure of the plist can be recovered by using collections.OrderedDict (although the order of keys shouldn’t be important in plist files).

XML data for the FMT_XML format is parsed using the Expat parser from xml.parsers.expat – see its documentation for possible exceptions on ill-formed XML. Unknown elements will simply be ignored by the plist parser.

The parser for the binary format raises InvalidFileException when the file cannot be parsed.

New in version 3.4.

doc_python
2016-10-07 17:40:49
Comments
Leave a Comment

Please login to continue.