我正在编写一个基于文本的游戏,它使用vb.net控制台应用程序作为GUI。但是,游戏本身实际上是在python中运行,因为它更适合编写脚本。如何将输出从python发送到vb.net,并将在vb.net应用程序中获得的输入发送到python脚本?我将在此处包含我的vb.net代码:
Public Module porkDisplay
Class Err
Private code As Integer
Private str As String
Public Sub New(ByVal code As Integer, ByVal str As String)
Me.code = code
Me.str = str
End Sub
Sub Run()
REM Send Me.code to an error handling python script
MsgBox(Me.str)
End Sub
End Class
Class CommandIntepreter
Private code As Integer
Public Sub New(ByVal code As Integer)
Me.code = code
End Sub
Sub GetData(ByVal data As String, ByVal runtimeerror As Err)
If data.Length = 0 Then
runtimeerror.Run()
Else
REM send data to python
End If
End Sub
End Class
Sub Main()
Dim standardInput As CommandInterpreter = New CommandInterpreter(0)
Dim nullInputErr As Err = New Err(0, "ERROR! Null Input Detected")
Console.WriteLine("Good Morning")
standardInput.GetData(Console.ReadLine(), nullInputErr)
End Sub
End Module
答案 0 :(得分:2)
这可能不是SO标准中的问题,但您可以使用几乎所有内容,从简单的文本或JSON文件,通过套接字到本地数据库。