当前位置:网站首页>XII Golang others
XII Golang others
2022-07-04 05:24:00 【Willing to ride the long wind and break thousands of miles of w】
1. Execute the script
as follows golang It can be executed python Script
package main
import (
"fmt"
"os/exec"
)
func main() {
cmd := exec.Command("/usr/local/bin/python3.9", "/Users/haha/GolandProjects/awesomeProject5/test.py")
// The error output and standard output of the command are connected to the same pipe
stdout, err := cmd.StdoutPipe()
cmd.Stderr = cmd.Stdout
if err != nil {
return
}
err = cmd.Start()
if err != nil {
return
}
// Get the output from the pipeline in real time and print it to the terminal
for {
tmp := make([]byte, 1024)
_, err := stdout.Read(tmp)
fmt.Print(string(tmp))
if err != nil {
break
}
}
if err = cmd.Wait(); err != nil {
return
}
}
python The script is as follows :
#!usr/bin/python3
assert 3 == 4
Execution results :
Traceback (most recent call last):
File "/Users/haha/GolandProjects/awesomeProject5/test.py", line 2, in <module>
assert 3 == 4
AssertionError
err = exit status 1
边栏推荐
- Error response from daemon: You cannot remove a running container 8d6f0d2850250627cd6c2acb2497002fc3
- 力扣 第 300 场周赛
- National vocational college skills competition (secondary vocational group) network security competition questions - Analysis
- [untitled]
- Supplement the JS of a video website to decrypt the video
- 光模块字母含义及参数简称大全
- LabVIEW错误对话框的出现
- Customize a pager needed in your project
- 【兴趣阅读】Adversarial Filtering Modeling on Long-term User Behavior Sequences for Click-Through Rate Pre
- Zhongke panyun-2022 Guangdong Trojan horse information acquisition and analysis
猜你喜欢
随机推荐
Flink1.13 SQL basic syntax (I) DDL, DML
Electronic components mall and data manual download website summary
2022 a special equipment related management (elevator) examination questions simulation examination platform operation
LabVIEW错误对话框的出现
Yyds dry goods inventory TCP & UDP
Useful plug-ins for vscode
2022年T电梯修理操作证考试题库及模拟考试
Notepad++ -- display related configurations
Trie数-字典树
Principle and practice of common defects in RSA encryption application
LM small programmable controller software (based on CoDeSys) note 22: error 4268/4052
[matlab] general function of communication signal modulation inverse Fourier transform
2022危险化学品经营单位安全管理人员上岗证题库及答案
中科磐云—D模块解析以及评分标准
Li Kou's 300th weekly match
[QT] timer
c语言经典指针和数组笔试题解析
Flutter calls Gaode map app to realize location search, route planning and reverse geocoding
TCP state transition diagram
如何使用postman实现简单的接口关联【增删改查】