On this page
marshal.dumps
Prev: marshal.dump | Up: marshal | Next: marshal.load
Rel: marshal.dump, marshal.load, marshal.loads
Ref: docs.python.org — marshal.dumps
Tags: #public #python3 #stdlib #marshal
Import
import marshal
from marshal import dumps
Signature & Overview
marshal.dumps(value, version=5, /, *, allow_code=True)
Return the bytes object that would be written to a file by dump(value, file).
Usage
import marshal
raw = marshal.dumps({"a": 1, "b": [2, 3]})
assert marshal.loads(raw) == {"a": 1, "b": [2, 3]}
Gotchas
- Unsafe on untrusted bytes: Use
jsonorsqlite3for application data.
REPL Inspect
from marshal import dumps
help(dumps)
Linked from
Related notes
- tuts/python3/stdlib_module/marshal/dump Linked here; links to this page; shared tags: #marshal, #stdlib
- tuts/python3/stdlib_module/marshal/load Linked here; links to this page; shared tags: #marshal, #stdlib
- tuts/python3/stdlib_module/marshal/loads Linked here; links to this page; shared tags: #marshal, #stdlib
- tuts/python3/stdlib_module/marshal Linked here; links to this page; shared tags: #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
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib