Python如何开发自动运行终端命令行? Resolved
Tofloor
poster avatar
Ligocut光剪视频剪辑软件
deepin
Backbone of ecological co-construction group
2018-02-01 20:45
Author
如题,想用Python开发,自动运行命令,但是最好或者不能启动终端软件,假如启动终端软件那样子时间就增加了,最好是直接就一段命令字符串,然后运行,出结果。
Reply Favorite View the author
All Replies
avatar
wangyong
deepin
2018-02-01 21:09
#1
subprocess这个python库
Reply View the author
avatar
h3l
deepin
2018-02-01 22:03
#2
跟进老王的步伐来装逼下,表明在下是能吃干饭的,哈铪铪。。。。。
Reply View the author
Comments
wangyong
2018-02-01 22:26
你骨骼很清秀
avatar
Ligocut光剪视频剪辑软件
deepin
Backbone of ecological co-construction group
2018-02-02 08:27
#3
wangyong 发表于 2018-2-1 13:09
subprocess这个python库

谢谢王总,过年回去看看先
Reply View the author
avatar
Ligocut光剪视频剪辑软件
deepin
Backbone of ecological co-construction group
2018-02-02 08:33
#4
wangyong 发表于 2018-2-1 13:09
subprocess这个python库

但是必须只能用进程间通信来调用命令吗?可不可以直接用Python操作,省去中间环节?
Reply View the author
avatar
wangyong
deepin
2018-02-02 16:32
#5
berners 发表于 2018-2-2 00:33
但是必须只能用进程间通信来调用命令吗?可不可以直接用Python操作,省去中间环节? ...

你可以自己操作tty的代码,自己做一个和shell交互的程序,看你的目标是干嘛,如果就是去的shell命令的结果,subprocess这个库就可以了
Reply View the author
avatar
梦幻大陆
deepin
2018-03-27 20:10
#6
最简单的是:os.system('ls -a')
Reply View the author