WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

Use Python serialization methods to export an expression to a Wolfram Language input.

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
  • export deals with serialization to both InputForm and WXF.

Serialize a Python object

Many Python built-in types are serialized to their Wolfram Language counterparts:

export({'int': 1, 'bool': True, 'string': 'hello'})

Use ByteArrayToString to create a string from the binary data returned by export:

Convert to a Wolfram Language expression using ToExpression:

Extract the Values from the association:

Verify types with Head:

Write arbitrary Wolfram Language expressions in Python

Create an expression in Python using the wl function:

from wolframclient.language import wl wl_expr = wl.Graphics3D(wl.Sphere())

Export it using the default InputForm format:

export(wl_expr)

Use ByteArrayToString to create a string from the binary data returned by export:

Convert to a Wolfram Language expression using ToExpression :

Notes

For more advanced usage of serialization, please see the Wolfram Client Library for Python documentation.

Related Functions

ByteArrayToString   ToExpression   Values   Head   InputForm

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /