我在Python中有以下代码
import subprocess
import time
info = subprocess.STARTUPINFO()
info.dwFlags |= subprocess.STARTF_USESHOWWINDOW
info.wShowWindow = subprocess.SW_HIDE
t1 = time.clock()
h = subprocess.Popen([r"C:\Users\MyName\Desktop\test.exe"], startupinfo=info)
h.communicate()
t2 = time.clock()-t1
print "Return Code:", h.returncode
print "Duration:", t2
如果我正在寻找程序的返回代码,那么这很有用,但如果我想抓住程序只是在屏幕上显示并在Python中将它们作为变量操作的话会怎样?