您的位置:首页 > 运维架构 > Shell

python运行shell命令并得到返回结果(比C++方便多了)

2012-11-30 21:03 549 查看
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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: