我想阻止运行时可见的输出suprocess.call调用()。
这是我要停止的唯一输出,因为我需要在后面运行的命令来显示。
调用显示的是我的密码,我将其设置为系统变量,在执行的文件中隐藏为%%mypassword%%(但是,它会显示在命令行界面中)。你知道吗
from subprocess import call
with open('//path/pwhold.txt','w') as pwhold:
call(r"\\filetorun\%s.bat" % DB,stdout=pwhold)
os.unlink('//path/pwhold.txt')
这种方法是可行的,但是在文件执行完成之前不会删除该文件。 还有别的办法吗?你知道吗
根据塞巴斯蒂安的评论。所使用的接口子流程调用()需要实际的文件句柄才能在操作系统级别捕获输出。执行命令时,尝试使用字符串或字符串缓冲区失败。你知道吗
忽略:这不起作用。 将STDOUT重定向到字符串而不是文件。这样,您的信息只会出现在内存中。看这个问题Can I redirect the stdout in python into some sort of string buffer?。你知道吗
TLDR公司: 用途:
或者
相关问题 更多 >
编程相关推荐