Python标准输出不打印或保存

时间:2018-06-05 12:59:56

标签: python

我正在尝试将子进程中的文本消息保存在变量中,但它们不会保存,也不会再打印。有人可以解释我为什么,因为我很困惑:

import os
import subprocess
import sys
import re

locationOfFile='C:\\Users\\admin\\Desktop\\..........txt'

command="cmd"
subprocess.Popen(command)

process="mycommand"

command3=subprocess.Popen(process, stdout=subprocess.PIPE)

#Usially with this command in the child process I  receave many messages, but with stdout I dont see them. I dont want to hide them from the console, just to go in that variable as a string "resultt"
resultt=command3.communicate()

print(resultt)
#But it is not printing?

0 个答案:

没有答案