python运行shell命令并得到返回结果(比C++方便多了)
2012-11-30 21:03
549 查看
1、
2、
输出结果:
['hello,world!\n', '1\n']
1
------------------------------------------------------
import os; os.system(command)
2、
import os; lss = os.popen('python d:\\test.py').readlines(); print "输出结果:" print lss; print int(lss[1]);
输出结果:
['hello,world!\n', '1\n']
1
------------------------------------------------------
#test.py import time; while 1: print "hello,world!"; print 1; time.sleep(2); break;
相关文章推荐
- 在python中执行shell命令,并以字符串形式返回命令执行结果
- python 运行多条shell命令
- shell脚本命令 运行python文件&python命令行运行python代码
- 运行dos命令,并查看返回结果
- python输出shell命令执行结果
- Java调用Linux下的shell命令并将结果以流的形式返回
- android代码执行adb shell终端命令(linux命令)并返回执行结果
- Linux中用C语言执行shell命令并获取返回结果
- Python获取命令实时输出-原样彩色输出并返回输出结果
- 获取python执行shell命令的结果
- Python运行Shell命令
- PHP调用python,shell命令执行成功,web运行失败
- Python编写的客户端给服务器发送指令执行相应的命令并返回结果
- Linux C 执行shell命令并获取返回结果
- C/C++获取shell命令返回值
- Python编写的客户端给服务器发送指令执行相应的命令并返回结果
- shell脚本中蛮量替换(将命令运行结果存入变量中)
- python 执行shell命令并将结果保存的实例
- shell中oracle执行sql并得到返回结果
- C++中,如何执行一个控制台命令并返回结果到字符串string中