This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
import os | |
# 1. 加载 Go 编译的动态库 | |
# 注意:路径可能需要根据你的操作系统调整 | |
lib = ctypes.CDLL(os.path.join(os.getcwd(), "libmymath.so")) | |
# 2. 定义函数的参数和返回类型 (类型映射) | |
lib.Add.argtypes = [ctypes.c_int, ctypes.c_int] | |
lib.Add.restype = ctypes.c_int |