模板python程序
camazotz的Python项目详细描述
卡马佐兹
python代码中的c代码
简介
camazotz用python代码编译和加载c代码。特别是 允许将C代码直接插入到Python文件中,可以 通过cTypes动态链接和调用。
设置
pip install camazotz
用法
exportCC="gcc"
importcamazotzlibrary=camazotz.C(""" #include <stdio.h> int factorial(int x){ int result = 1; while (x > 1){ result *= x; x--; } return result; } """)function_factorial=library["factorial"]print("5! =",function_factorial(5))print("4! =",function_factorial(4))