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")
更直觀一些。



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM