在Windows UWP app中将Python与C#一起使用 [英] Use Python alongside C# in Windows UWP app

查看:204
本文介绍了在Windows UWP app中将Python与C#一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始用Python编写应用程序,但是现在我想切换到C#和UWP.我知道您不能用Python编写UWP应用,但是我试图查看我是否可以用Python编写一些代码并从C#访问该代码.

例如,用Python编写一个C#代码也可以访问的类.那可能吗?如果可以,Python是否可以访问Microsoft的UWP API?

主代码不会用Python编写;那将是不可能的.但是C#和Python之间是否可能存在互操作性,也许与IronPython(.NET的Python)兼容?

我将如何设置这样的Visual Studio项目?我已经安装了适用于Visual Studio的Python工具,但是没有内置选项可将Python文件添加到我的UWP应用中.

解决方案

由于框架的限制,当您通过沙箱运行应用程序时,由于框架限制,c#中的经典" python解释器(作为IronPython)在商店应用程序中不起作用./p>

有些人已经将完整的python解释器移植到WinRT 关于汞问题 .当然,由于框架的限制,整个标准库不可用. 这与WinRT一起使用,因此很可能在UWP上工作.

I started writing an application in Python, but I now want to switch to C# and UWP. I know that you cannot write a UWP app in Python, but I am trying to see if I can write some code in Python and access that code from C#.

For example, writing a class in Python that C# code can access as well. Is that possible? And if so, can Python access Microsoft's UWP APIs?

The main code will not be written in Python; that would be impossible. But can interoperability between C# and Python exist, perhaps with IronPython (.NET's Python)?

And how would I set up such a Visual Studio project? I have Python Tools for Visual Studio installed, but there was no built-in option to add a Python file to my UWP app.

解决方案

'Classic' python interpreters in c# (as IronPython) don't work in store apps because of framework restrictions, as you run your app through a sandbox.

Some dude has ported the full python interpreter to WinRT on mercurial. Of course, due to framework restrictions, the whole standard library isn't available. This works with WinRT, so it will very likely work on UWP.

这篇关于在Windows UWP app中将Python与C#一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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