pu369com

golang执行带空格的cmd命令

例如:

cmd中执行:    adb shell input keyevent 26

需要 :  exec.Command("adb", "shell", "input", "keyevent", "26").Run()

可以写成:
//直接运行cmd命令
func A(s string) {
	str0 := strings.Split(s, ` `)
	str1 := str0[0]
	str2 := str0[1:]
	exec.Command(str1, str2...).Run()
}
然后:
A("adb shell input keyevent 26")
更直观一些。


posted on 2020-06-30 16:36  pu369com  阅读(1112)  评论(0编辑  收藏  举报

导航