首先把Python中的两个模块导入(platform和ctypes模块),其中ctypes模块提供和C语言兼容的数据类型,能够很方便地调用动态链接库中输出的C接口函数。
import platform
import ctypes
#运行环境判断
systype = platform.system()
if systype == 'Windows':
if platform.architecture()[0] == '64bit':
zauxdll = ctypes.WinDLL('./zauxdll64.dll')
print('Windows x64')
else:
zauxdll = ctypes.WinDLL('./zauxdll.dll')
print('Windows x86')
elif systype == 'Darwin':
zmcdll = ctypes.CDLL('./zmotion.dylib')
print("macOS")
elif systype == 'Linux':
zmcdll = ctypes.CDLL('./libzmotion.so')
print("Linux")
else:
print("Not Supported!!")
楼主最近还看过