CPython与.net c#PInvoke类似吗?Python有类似于.net c#PInvoke的东西吗?
例如我有some.dll或some.so,并希望在运行时注册一些函数,并开始在我的程序中使用它们。
在C#中,你可以这样做:
// Marshal.cs
using System;
using System.Runtime.InteropServices;
namespace CSharpIterators
{
class MainClass
{
[DllImport("msvcrt.dll")]
public static extern int puts([MarshalAs(UnmanagedType.LPStr)] string m);
[DllImport("msvcrt.dll")]
internal static extern int _flushall();
public static void Main (string[] args)
{
puts("Hello World!");
_flushall();
}
}
}
做Python有类似的功能?
在此先感谢!