import (
    "fmt"
    "os/exec"
    "bytes"
)

func main() {
    cmd :="/root/hi.py > /root/1.log"

    out,err:= exec.Command("python","-c",cmd).Output()
    fmt.Printf("Out: %s ", string(out))
    fmt.Printf("Err: %s ", err.Error())

}

错误:没有此类文件错误:/root/hi.py> /root/1.log
//hi.py

#! /usr/bin/python

print('hello world')

最佳答案

文件hi.py位于何处?尝试按参数将其拆分,似乎尝试使用文件名/root/hi.py > /root/1.log

关于go - 为什么我从golang运行python脚本错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47256497/

10-08 22:44
查看更多