使用 Python 代码中的 .Net 程序集

使用 IronPython,你可以访问使用与 IronPython 核心相同或更低版本编译的任何 .net 程序集。

示例:导入 aa .net 程序集和类

from System import Math

示例:使用导入的类:

from System import Math
print Math.Abs(-123)

你还可以使用内置的 clr 模块加载其他程序集。

import clr
clr.AddReference('Sample') # Sample.dll inside of the working directory.

而不仅仅是使用它作为任何其他 .net 或 python 库。