使用“gopy”,如何正确地将[]字符串从Python传递到Go?

使用“gopy”,如何正确地将[]字符串从Python传递到Go?,python,go,Python,Go,我的密码是: func Test(websites []string) { fmt.Print("test") } 我使用gopybuild生成httpget.so文件 然后,我尝试加载ans,并在Python代码中使用此模块httpget.so: import httpget print dir(httpget) httpget.Test(["aaaa"]) 但是调用该函数会导致一种恐慌: panic: runtime error: invalid memory address

我的密码是:

func Test(websites []string) {
    fmt.Print("test")
}
我使用
gopybuild
生成
httpget.so
文件

然后,我尝试加载ans,并在Python代码中使用此模块
httpget.so

import httpget
print dir(httpget)

httpget.Test(["aaaa"])
但是调用该函数会导致一种恐慌:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x1 pc=0x103998688]

goroutine 17 [running, locked to thread]:
main.cgo_func_httpget_Test(0x1)
    /private/var/folders/yg/tx1wr1c5233fd299lpqnvjy40000gn/T/gopy-066392802/httpget.go:173 +0x18

goroutine 18 [syscall, locked to thread]:
runtime.goexit()
    /usr/local/Cellar/go/1.5.1/libexec/src/runtime/asm_amd64.s:1696 +0x1

我该如何解决这个问题?

好的,我找到了解决方法!!23333

戈兰

var (
    WebSites = [1]string{"aaa"}
)
在python中

import httpget
s = httpget.GetWebSites()
s[0] = "http://www.baidu.com"
httpget.Test(s)

你的函数接受一个
字符串
而不是
[]字符串
对不起,代码是
func Test(网站[]字符串){fmt.Print(网站)}
如果你在
Test()
的主体中只使用
fmt.Println(“Test”)
?@kostix不,调用TestUh的参数太多了,什么?我的意思是,用
fmt.Println(“test”)
替换
fmt.Print(网站)
,但保持两边代码的其余部分不变。我没有告诉您不要将数据传递到
Test()
,只是为了在该函数中忽略它,以了解它是否无法访问参数数据或更早。