【发布时间】:2020-01-30 18:29:44
【问题描述】:
private void RunApp_Click(object sender, RoutedEventArgs e)
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Python\PythonCore\3.7\InstallPath");
if (key != null)
{
object path = key.GetValue("ExecutablePath");
string comm = "/C " + System.IO.Path.GetDirectoryName(path as string) + @"\python " +
System.IO.Path.GetDirectoryName((string)SelectProjectFolder.Content) + "main.py";
System.Diagnostics.Process.Start("cmd.exe", comm);
}
}
错在哪里?控制台在没有命令的情况下打开并立即关闭。用etip做什么。我需要通过控制台运行一个 .py 文件。我通过 Key 获取 Python 的路径并将路径添加到 Py 文件。但是当您在控制台中打开命令时,不会。 (谷歌翻译)
【问题讨论】:
-
在调用 process.start 之前使用调试器检查 comm 变量的内容
-
预期行为,例如当您双击 yhe py 文件时
标签: c# python-3.x wpf cmd