1
我用swig從c創建一個python文件。我已經將c文件轉換爲.py文件,當我嘗試調用c程序的函數時,出現錯誤 AttributeError:'模塊'對象沒有屬性'fact'Python:AttributeError:'模塊'對象沒有屬性
我的C文件是
/* File : example.c */
#include <time.h>
double My_variable = 3.0;
int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}
int my_mod(int x, int y) {
return (x%y);
}
char *get_time()
{
time_t ltime;
time(<ime);
return ctime(<ime);
}
我的接口文件是
/* example.i */
%module example
%{
/* Put header files here or function declarations like below */
extern double My_variable;
extern int fact(int n);
extern int my_mod(int x, int y);
extern char *get_time();
%}
有人能幫助我嗎?