On this page
plistlib.dump
Up: plistlib | Next: plistlib.dumps
Rel: plistlib.dumps, plistlib.InvalidFileException, plistlib.load, plistlib.loads
Ref: docs.python.org — plistlib.dump
Tags: #public #python3 #stdlib #plistlib
Import
import plistlib
from plistlib import dump
Signature & Overview
plistlib.dump(value, fp, *, fmt=<PlistFormat.FMT_XML: 1>, sort_keys=True, skipkeys=False, aware_datetime=False)
Write 'value' to a .plist file. 'fp' should be a writable, binary file object.
Usage
import io
import plistlib
buf = io.BytesIO()
plistlib.dump({"Label": "com.example.job", "RunAtLoad": True}, buf)
buf.seek(0)
assert plistlib.load(buf)["RunAtLoad"] is True
Gotchas
- Requires binary file mode (
"wb"): Passfmt=plistlib.FMT_BINARYfor compact binary plists (default isFMT_XML).
REPL Inspect
from plistlib import dump
help(dump)
Linked from
Related notes
- tuts/python3/stdlib_module/plistlib/dumps Linked here; links to this page; shared tags: #plistlib, #stdlib
- tuts/python3/stdlib_module/plistlib/InvalidFileException Linked here; links to this page; shared tags: #plistlib, #stdlib
- tuts/python3/stdlib_module/plistlib/load Linked here; links to this page; shared tags: #plistlib, #stdlib
- tuts/python3/stdlib_module/plistlib/loads Linked here; links to this page; shared tags: #plistlib, #stdlib
- tuts/python3/stdlib_module/plistlib Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/plistlib/UID links to this page; shared tags: #plistlib, #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib