windows下cmd运行python文件的问题
巴扎黑
巴扎黑 2017-04-17 17:59:01
0
1
447

1.cmd中运行python文件。python.exe路径+空格+python文件路径+空格+参数(参数之间用空格隔开)
2.单独运行没有问题,目前发布成服务需要并行调用,会出现cmd调用不起来python的问题,请解答(就是在cmd中输入1中的格式,没有任何响应)

巴扎黑
巴扎黑

reply all(1)
大家讲道理
 using (System.Diagnostics.Process process = System.Diagnostics.Process.Start(procStartInfo))
        {
            using (StreamReader reader = process.StandardOutput)
            {
                string result = reader.ReadToEnd();
                return result ;
            }
        }
        

What you mean is to execute python, start it as a child process, and then check the program output. Check whether your python code has a print action at the last place. If not, then your C# should be blocked in reading python output and has been waiting for the program to complete execution. Suggest you

System.Diagnostics.Process.Start(procStartInfo)
执行完之后断点,看下进程表里python启动没有
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template