Python marshal Module
Example
Serialize and deserialize a simple value:
import marshal
data = 42
dumped = marshal.dumps(data)
print(dumped)
print(marshal.loads(dumped))
Try it Yourself »
Definition and Usage
The marshal module serializes and deserializes Python values to a binary format.
It is intended for internal use (like .pyc files) and not secure against untrusted data.
Members
Member | Description |
---|---|
dumps() | Serialize an object to bytes. |
dump() | Serialize an object and write to a file-like object. |
loads() | Deserialize bytes to a Python object. |
load() | Deserialize from a file-like object. |