简体   繁体   English

我如何知道我使用的是哪个 Python 解释器?

[英]How do I tell which Python interpreter I'm using?

I am using Python 2.5.2.我正在使用 Python 2.5.2。 How can I tell whether it is CPython or IronPython or Jython ?我如何判断它是CPython还是IronPythonJython

Another question: how can I use a DLL developed in VB.NET in my project?另外一个问题:如何在我的项目中使用VB.NET开发的DLL?

import platform    
platform.python_implementation()

The above one provide the type of interpreter you use.以上提供了您使用的解释器类型。

If you downloaded it as the default thing from python.org, it's CPython.如果你从 python.org 下载它作为默认的东西,它就是 CPython。 That's the “normal” version of Python, the one you get when you use the command “python”, and the one you'll have unless you specifically went looking for the projects targeting Java/CIL.这是 Python 的“正常”版本,当您使用命令“python”时得到的版本,除非您专门去寻找针对 Java/CIL 的项目,否则您将拥有这个版本。

And it's CPython because neither of the other projects have reached version number 2.5.2.它是 CPython,因为其他项目都没有达到版本号 2.5.2。

How can i use a dll developed in VB.NET in to my project?我如何在我的项目中使用在 VB.NET 中开发的 dll?

From CPython, using Python-for-.NET (*) and clr.AddReference.从 CPython,使用Python-for-.NET (*) 和 clr.AddReference。

(*: actually a bit of a misnomer, as with CPython in control it is more like .NET-for-Python.) (*:实际上有点用词不当,因为控制 CPython 它更像是 .NET-for-Python。)

If you are typing "python" to launch it, it is probably CPython.如果您输入“python”来启动它,它可能是 CPython。 IronPython's executable name is "ipy". IronPython 的可执行文件名称是“ipy”。

import sys
print sys.version

Well since the first part of your question has been answered, I'll tackle the second part.既然你的问题的第一部分已经得到回答,我将解决第二部分。 .NET dll's can be accessed from python in various ways.可以通过多种方式从 python 访问 .NET dll。 If you are using ironpython it makes this especially easy, since all .NET languages can interact with eachother fairly seamlessly.如果您使用的是 ironpython,这会变得特别容易,因为所有 .NET 种语言都可以相当无缝地相互交互。 In this case you would access your dll from ironpython just as you would any other .NET dll you made with ironpython.在这种情况下,您将从 ironpython 访问您的 dll,就像您使用 ironpython 创建的任何其他 .NET dll 一样。 If you want to call a native dll you can use ctypes .如果你想调用本机 dll 你可以使用ctypes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM