Как передать C# словарь в качестве аргумента в Python скрипт?
Есть ли возможность при запуске процесса внутри C# передавать в качестве аргумента не просто строки, а коллекции, в частности, словари?
private Dictionary<string, string> toMethod = new Dictionary<string, string>()
{
{ "Forward fill", "ffill" },
{ "Backward fill", "bfill" },
};
private void run_python(string cmd, string args)
{
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = "my/full/path/to/python.exe";
start.Arguments.Add(toMethod); // Что-то подобное
start.UseShellExecute = false;
start.RedirectStandardOutput = true;
using(Process process = Process.Start(start))
{
using(StreamReader reader = process.StandardOutput)
{
string result = reader.ReadToEnd();
Console.Write(result);
}
}
}
Источник: Stack Overflow на русском