当前位置:网站首页>十二. golang其他
十二. golang其他
2022-07-04 05:05:00 【愿乘长风、破万里浪】
1. 执行脚本
如下golang可以执行python脚本
package main
import (
"fmt"
"os/exec"
)
func main() {
cmd := exec.Command("/usr/local/bin/python3.9", "/Users/haha/GolandProjects/awesomeProject5/test.py")
// 命令的错误输出和标准输出都连接到同一个管道
stdout, err := cmd.StdoutPipe()
cmd.Stderr = cmd.Stdout
if err != nil {
return
}
err = cmd.Start()
if err != nil {
return
}
// 从管道中实时获取输出并打印到终端
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脚本如下:
#!usr/bin/python3
assert 3 == 4执行结果:
Traceback (most recent call last):
File "/Users/haha/GolandProjects/awesomeProject5/test.py", line 2, in <module>
assert 3 == 4
AssertionError
err = exit status 1边栏推荐
- Enterprise level log analysis system elk (if things backfire, there must be other arrangements)
- flink1.13 sql基础语法(二)join操作
- [matlab] matlab simulation - simulate the AM modulation process of the modulation system
- Using jsts in esmodule environment
- appliedzkp的zkevm(12)State Proof
- 【QT】制作MyComboBox点击事件
- Headache delayed double deletion
- Build an Internet of things infrared temperature measuring punch in machine with esp32 / rush to work after the Spring Festival? Baa, no matter how hard you work, you must take your temperature first
- [技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术
- TCP状态转换图
猜你喜欢

Flutter ‘/usr/lib/libswiftCore. dylib‘ (no such file)

小程序毕业设计---美食、菜谱小程序

中科磐云—D模块解析以及评分标准

2022年R2移动式压力容器充装复训题库及答案

中職組網絡安全—內存取證

全国职业院校技能大赛(中职组)网络安全竞赛试题—解析

【QT】定时器

中科磐云—2022广东木马信息获取解析

简单g++和gdb调试
![[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre](/img/3e/b5df691ca1790469eb1b4e8ea5b4c0.png)
[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre
随机推荐
[matlab] communication signal modulation general function interpolation function
Ping port artifact psping
A summary of the 8544 problem that SolidWorks Standard cannot obtain a license
记几个智能手表相关芯片 蓝牙芯片 低功耗
Write a complete answer applet (including single choice questions, judgment questions and multiple topics) (III) single choice questions, judgment questions, and the first question display
2022 t elevator repair operation certificate examination question bank and simulation examination
JS string splicing
Remote desktop client RDP
Yyds dry goods inventory TCP & UDP
中职组网络安全—内存取证
Just do it with your hands 7 - * project construction details 2 - hook configuration
Redis realizes ranking function
Flutter calls Gaode map app to realize location search, route planning and reverse geocoding
Graduation design of small programs -- small programs of food and recipes
Just do it with your hands 7 - * project construction details 2 - hook configuration
[untitled]
Flutter ‘/usr/lib/libswiftCore. dylib‘ (no such file)
Unity is connected to the weather system
[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre
flink1.13 sql基础语法(二)join操作