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
script
stringThe Python script to execute as a string.
multiLineResult
boolA 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
EncodingThe 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.