从.NET调用Python [英] Call Python from .NET

查看:476
本文介绍了从.NET调用Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些code用Python编写的,不能被转移到一个.NET语言。我需要从我的。NET的WinForms应用程序中调用这些函数之一。

现在,我这样做是通过启动Python脚本作为一个单独的进程和向它传递参数作为命令行参数。它的工作原理,但我真的不喜欢这个解决方案。我希望能够提升到一个更好的。

有没有什么更好的方法来从.NET应用程序调用的.py 脚本的功能?什么是做到这一点的最好方法是什么?

注: IronPython的是不是一种选择作为这个Python脚本

解决方案
  

它的工作原理,但我真的不喜欢这个解决方案,我希望能够提升到一个更好的。

没有,AFAIK有没有更好的解决办法,尤其是如果IronPython的是一个没有没有你。所以,你仍然可以保留这是一个临时的解决办法,同时等待脚本迁移到.NET或直到你发现已经有人写了.NET库,为您​​提供类似的功能。

I have some code written in Python which can not be transferred to a .NET language. I need to call one of these functions from my .NET WinForms application.

Now, I do it by starting the Python script as a separate process and pass parameters to it as command line arguments. It works, but I don't really like this solution. I'd like to improve it to a better one.

Is there any better way to call a function of a .py script from a .NET application? What is the best way to do it?

Note: IronPython is NOT an option for this Python script

解决方案

It works, but I don't really like this solution, I'd like to improve it to a better one.

No, AFAIK there isn't a better solution, especially if IronPython is a no-no for you. So you could still keep this as a temporary workaround while waiting for the script to be migrated to .NET or until you find that someone already wrote a library on .NET that provides you with similar functionality.

这篇关于从.NET调用Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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