Created
September 25, 2019 03:48
-
-
Save gopher1980/587ed95609dd790887544d3cb9901b5a to your computer and use it in GitHub Desktop.
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
package main | |
/* | |
#cgo pkg-config: python-3.7 | |
#define PY_SSIZE_T_CLEAN | |
#include <Python.h> | |
int run (const char * code) { | |
return PyRun_SimpleString(code); | |
} | |
*/ | |
import "C" | |
import "fmt" | |
func main() { | |
C.Py_Initialize(); | |
defer C.Py_Finalize() | |
e := C.run(C.CString(` | |
import time | |
def multiply(a,b): | |
c = 0 | |
for i in range(0, a): | |
c = c + b | |
return c | |
print(multiply(2,3)) | |
print('OK!!') | |
`)) | |
fmt.Println(e) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment