问题描述
我希望有人也许能帮助我在这里。我是比较新的C#,我试图执行一些Python代码,我从C#winform应用程序中写道。
I am hoping that someone might be able to help me out here. I am relatively new to C# and am trying to execute some Python code I wrote from within a C# winform app.
我想什么做的是输入与一个名字在WinForm中的文本框,并把它通过Python脚本过程和在WinForm另一个文本框返回结果。
What I would like to do is input a name from a text box within the winform and have it process through the python scripts and return a result in another textbox on the winform.
我已经找到了如何执行C#中的一个脚本几个很好的例子,但我有一些无法理解我怎么可以参考多个脚本。
I have found several good examples of how to execute a single script within C#, but I am having some trouble understanding how I can reference multiple scripts.
作为一个例子,我有一个python脚本引用在代码中另外两个脚本
As an example, I have one python script that references two other scripts within code
from FindTelephone import *
from FindAddress import *
def createPerson(name)
telephone = FindTelephone(name)
address = FindAddress(name)
....
有没有办法让C#点运行前我的其他Python脚本的参考我的主要脚本?
Is there a way to have C# point to a reference of my other python scripts before running my main script?
在您的帮助感谢。
马歇尔
推荐答案
像这些职位?:
,
运行一个python脚本?
Like in these posts?:Call Python function from c# (.NET),run a python script from c#?
或
您可能要考虑的。
或
如果您希望的方式easyer这样做的话,我建议使用的。 IronPython的是紧密与.NET Framework集成Python编程语言的开源实现。也就是说,它是非常easyer用C#和Windows窗体使用,看起来几乎就像普通的Python。
If you want an easyer way of doing this then I recommend using Iron Python in place of normal Python. IronPython is an open-source implementation of the Python programming language which is tightly integrated with the .NET Framework. Means that it is much easyer to use with C# and Windows Forms and looks almost just like normal Python.
或
有关如果你正在使用Visual Studio,VS有一些Python的工具,可以帮助你在你的追求。 。你可以找到更多的文档这。最后一个环节是由杰迪戴亚提供从意见中投票他的意见,如果你喜欢这最后一个环节。
For in case you are using Visual Studio, VS has some Python tools that might help you in your quest. Link. You can find more documentation Here This last link is provided by Jedediah from comments so vote his comment up if you liked this last link.
其他方便的链接:
这篇关于从运行C#几个Python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!