반응형
c에서 python 호출하기 ][ test
■ 사용법
This file contains 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
/* | |
test by kyoung chip , jang | |
sudo apt-get install python-dev | |
sudo apt-get install python3-dev | |
gcc -o p1 p1.c -I/usr/include/python2.7 -lpython2.7 | |
*/ | |
#include <Python.h> | |
int main( void ) | |
{ | |
Py_Initialize(); | |
PyRun_SimpleString("import sys; sys.path.append('.')"); | |
PyRun_SimpleString("import callme;"); | |
PyRun_SimpleString("print( callme.test(\"test\") ) "); | |
Py_Finalize(); | |
return 0; | |
} |
This file contains 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
# | |
# test by kyoung chip , jang | |
# | |
def test( data ) : | |
return( "receive = %s " % data ) |

반응형
'Python > 0x05-ctypes' 카테고리의 다른 글
ctypes class ][ python에서 c++ class 사용하기 (0) | 2017.10.08 |
---|