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有類似的功能?
在此先感謝!