CPython是否有类似于.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有类似的功能吗?
提前致谢!