Table of Contents

Method RunPythonScriptViaTempFile

Namespace
Alternet.Common.Python
Assembly
Alternet.Common.Python.v10.dll

RunPythonScriptViaTempFile(string, bool, Encoding)

Executes a Python script using a temporary file. This method creates a temporary Python script file, writes the script content to it, executes the script, and then deletes the temporary file.

public static string RunPythonScriptViaTempFile(string script, bool multiLineResult = false, Encoding encoding = null)

Parameters

script string

The Python script to execute as a string.

multiLineResult bool

A boolean value indicating whether the output of the script should be treated as multi-line. If true, the output will include all lines; otherwise, only the first line will be returned.

encoding Encoding

The encoding to use when writing the script to the temporary file. If null, the default encoding is used.

Returns

string

The output of the Python script as a string, or null if an error occurs during execution.