执行exec外部python脚本并获取返回的输出

In my Go file i use exec to run the external script:

cmd := exec.Command("test.py")
out, err := cmd.CombinedOutput()
if err != nil {
    fmt.Println(err)
}
fmt.Println(string(out))

The python script it's executed fine, but the go fmt.Println(string(out)) prints nothing.

The question it's how i should return the value from the Python script to be read back again from Go?

Python pseudo code:

def main(): ... ... return value

I think i found the bug, you need to put the full path to "test.py"

Test

I have two files in a directory: test.py test.go

The test.py is:

#!/usr/bin/env python3

print("Hello from python")

and test.go is:

package main

import (
        "fmt"
        "os/exec"
)

func main() {

//cmd := exec.Command("test.py")
// I got an error because test.py was not in my PATH, which makes sense
// When i added './' the program worked because go knew where to find test.py
cmd := exec.Command("./test.py")
out, err := cmd.CombinedOutput()
if err != nil {
    fmt.Println(err)
}
fmt.Println(string(out))
}

And I get the following output:

$ go run ./test.go 
Hello from python