Method RunPythonScriptViaTempFile
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
scriptstringThe Python script to execute as a string.
multiLineResultboolA 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.
encodingEncodingThe 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
nullif an error occurs during execution.