如何解决Vb,净您如何处理要求多个用户输入的cmd进程
我有一个在后台运行python的进程,以便接收输入和输出。 我的程序可以有多个输出,但只能输入一个,否则程序将冻结。如果python.exe要为新用户输入使用不同的值,我该怎么做?
VB.net
Public Value As String
Private Sub Button1_Click(sender As Object,e As EventArgs) Handles Button1.Click 'Works on button
Dim p As Process = New Process
p.StartInfo.FileName = "C:\Users\luqma\AppData\Local\Programs\Python\Python38-32\python.exe" 'Default Python Installation
p.StartInfo.Arguments = "File.py"
p.StartInfo.UseShellExecute = False 'required for redirect.
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden 'don't show commandprompt.
p.StartInfo.CreateNoWindow = True
p.StartInfo.RedirectStandardInput = True
p.StartInfo.RedirectStandardOutput = True 'captures output from commandprompt.
p.StartInfo.RedirectStandardError = True
p.Start()
AddHandler p.OutputDataReceived,AddressOf process_OutputDataReceived
p.StandardInput.WriteLine(TextBox2.Text)
p.StandardInput.WriteLine(TextBox2.Text) 'Freezes with this input added. Only works with one use input
p.BeginOutputReadLine()
SimpleEditor1.Text = Value
p.WaitForExit()
End Sub
Public Sub process_OutputDataReceived(ByVal sender As Object,ByVal e As DataReceivedEventArgs)
On Error Resume Next
If e.Data = "" Then
Else
Value += ">" + e.Data + Environment.NewLine
End If
End Sub
我正在尝试做的Python代码
print("bye")
print("Hello")
i = int(input("Enter num:"))#RUNS WHEN THERE IS ONLY THIS INPUT
print(i+1)
q = int(input("Enter num:"))#FREEZES WHEN THIS IS IN THE PYTHON FILE
print(q+5)
感谢您的帮助
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。