问题描述
我已经成功对其进行了编码,以运行Python脚本并返回输出。但不幸的是,它仅返回最后一行。我想知道是否有办法从脚本中获取全部输出?
如果有人感兴趣,这是在后台运行脚本并返回输出的最后一行的代码。
Dim proc As Process = New Process
proc.StartInfo.FileName = "C:\Program Files\Python38\python.exe" 'Default Python Installation
proc.StartInfo.Arguments = "RunImageChecker.py arg1 arg2" 'Python script and arguments
proc.StartInfo.UseShellExecute = False 'required for redirect.
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
proc.StartInfo.CreateNoWindow = True
proc.StartInfo.RedirectStandardOutput = True 'captures output from commandprompt.
proc.Start()
AddHandler proc.OutputDataReceived,AddressOf proccess_OutputDataReceived
proc.BeginOutputReadLine()
proc.WaitForExit()
MsgBox(Value)
TextBox1.Text = Value
注意:python脚本必须与您的程序位于同一文件夹中,否则它将无法运行。我希望有办法解决这个问题,但是我找不到。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)