Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Python から.net DLL を呼び出す

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for tsuda.a tsuda.a
December 30, 2022

Python から.net DLL を呼び出す

Python (Iron Python ではなく、普通のいわゆる cPython (ver3系)) で .net core の DLL を呼び出してみた例です。

Avatar for tsuda.a

tsuda.a

December 30, 2022
Tweet

More Decks by tsuda.a

Other Decks in Programming

Transcript

  1. Visual Studio で dll を作成 (.net core で作ります) namespace PythonTestNamespace

    { public class PythonTestClass { public int Add(int value1, int value2) { return value1 + value2; } } }
  2. Python のコードを書く from pythonnet import load Load(“coreclr”) import clr clr.AddReference('PythonTest')

    from PythonTestNamespace import PythonTestClass test = PythonTestClass() ver = test.Add(1, 2) print(ver) .net core の CLR を使用 (これを書かないと .net framework になる) DLL を Load Class を Import