我有一个类函数声明为
def catFunc(self,filename):
print "catFunc",filename
process = subprocess.Popen(['cat',/root/scratch.php], stdout=subprocess.PIPE, shell=True)
out, err = process.communicate()
print (out)
print (err)
像这样打电话
fn = '/root/scratch.php'
self.catFunc(fn)
但我看不到输出,也不知道为什么
非常感谢您的帮助
要检索shell命令的输出,建议使用
subprocess.check_output
与shlex.split
配合使用。你知道吗例如:
也就是说,基于当前的问题标题,Rakesh是正确的。你知道吗
读取文件内容
如果需要使用子流程模块:
相关问题 更多 >
编程相关推荐