Use Python serialization methods to export an expression to the WXF format.
Import the Python function export from the Wolfram Client Library
The export function is the cornerstone of the serialization module:
from wolframclient.serializers import export
Serialize a Python object
Many Python built-in types are serialized to their Wolfram Language counterparts:
export({'float': 1.2, 'bool': False, 'string': 'hello world!', 'bytes': b'\x00\xFF'}, target_format='wxf')
Convert to a Wolfram Language expression using BinaryDeserialize:
Write arbitrary Wolfram Language expressions in Python
Create an expression in Python using the wl function:
from wolframclient.language import wl
wl_expr = wl.BarChart(wl.Range(5))
Export it to the WXF format by specifying it as the target format:
export(wl_expr, target_format='wxf')
Convert to a Wolfram Language expression using BinaryDeserialize:
Notes
For more advanced usage of serialization, please see the Wolfram Client Library for Python documentation.