示例代码:
package simple import ( fmt gopy ) func example(args *py.tuple) (py.object, error) { fmt.printf(simple.example: %v\n, args) py.none.incref() return py.none, nil } func init() { methods := []py.method{ {example, example, example function}, } _, err := py.initmodule(simple, methods) if err != nil { panic(err) } }
编译方法:
gopy pymodule.go
使用方法:
import simple
simple.example(hello, {123: true})
输出结果:
simple.example: [hello map[123:true]]
github开源项目地址:https://github.com/qur/gopy
