CPython有类似于.netc的东西吗?在
例如我有一些.dll或者一些。所以并希望在运行时从它注册一些函数并开始在我的程序中使用这些函数。在
在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有类似的功能吗?在
提前谢谢!在
可以使用Python的^{} module 从dll调用函数。在
另一个选择是使用像SWIG这样的工具来创建一个Python接口到C/C++代码: http://www.swig.org/
创建包装器的语法非常类似于C加上一些预处理指令。在
相关问题 更多 >
编程相关推荐