python在C#应用程序中的集成 [英] Integration of python in C# Application

查看:170
本文介绍了python在C#应用程序中的集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题:
我有一个用python编写的旧应用程序。此应用程序允许用户指定将要执行的小型python步骤,python步骤基本上是小型python脚本,我称它们为步骤,因为此应用程序的执行还涉及其他步骤,例如从命令行执行某些操作。这些python步骤作为python代码存储在xml文件中。

I have the following problem: I got an old application which is written in python. This application allows the user to specify small python steps which will be executed, python steps are basically small python scripts, I call them steps because the execution of this application involves other steps like executing something from commandline. These python steps are stored as python code in an xml file.

现在,我想使用C#.NET重写应用程序。有没有做这样的最佳实践解决方案?

Now I want to rewrite the application by using C# .NET. Is there a best practise solution to do something like this?

我不想将python作为外部程序调用,而是将实际的python step(script)传递给python解释器-我需要内置的东西。我刚遇到IronPython和.NET python,但是我不确定使用哪个。
我想对小脚本进行某种调试,这就是为什么调用解释器解决方案不可接受的原因。

I don't want to call python as external programm and pass the actual python step(script) to the python interpreter - I want something built in. I just came across IronPython and .NET python but I am not quite sure which one to use. I want to achieve some sort of debugging for the small scripts, that is why the call the interpreter solution is not acceptable.

更重要的是,其中许多脚本已经存在。因此,我必须使用python的C#实现,该实现具有与python相同的语法以及内置的python库。

What is more important is that a lot of those scripts already exist. Therefore I have to use a C# implementation of python which has the same syntax as python as well as the same built in libs of python. Is this even possible?

感谢和问候
Xeun

Thanks and Greetings Xeun

推荐答案

IronPython 是您想要的。它编译为.NET字节码。您可以合理地轻松地从另一种.NET语言调用python代码(反之亦然)。我认为Visual Studio也支持IronPython。

IronPython is what you want. It compiles to .NET bytecode. You can reasonably easily call python code from another .NET language (and the other way around). IronPython is supported in Visual Studio too, I think.

这篇关于python在C#应用程序中的集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆