【发布时间】:2019-01-25 05:41:32
【问题描述】:
我有一个富文本框,我在其中插入字符串值:- Archit Panda。
但我只从 python 脚本获取输出为“Archit”。
按钮上的 C# 代码:-
private void button13_Click(object sender, RoutedEventArgs e) {
TextRange textRange = new TextRange(richTextBox1.Document.ContentStart,richTextBox1.Document.ContentEnd);
string str = textRange.Text;
string FileName = @"C:\Users\Archit\AppData\Local\Programs\Python\Python37-32\python.exe";
// string myPythonApp = @"""C:\Users\Archit\Documents\Visual studio 2010\Projects\WpfApplication1\WpfApplication1\blockchain.py""";
string myPythonApp = @"blockchain.py";
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(FileName);
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
//Console.WriteLine(splitted.ToString());
myProcessStartInfo.Arguments = myPythonApp+ " " +str;
Process myProcess = new Process();
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
StreamReader myStreamReader = myProcess.StandardOutput;
string myString = myStreamReader.ReadLine();
myProcess.WaitForExit();
myProcess.Close();
Console.WriteLine("Value received from script: " + myString);
}
Python 脚本:-
!/usr/bin/python
导入系统
x = sys.argv[1] 打印(x)
我想以“Archit Panda”的形式输出。 你能告诉我我做错了什么吗?
【问题讨论】:
标签: c# python-3.x