Python 命令与子进程

Python 命令与子进程,python,subprocess,Python,Subprocess,只是想知道是否有人能告诉我原因 import subprocess, commands p=subprocess.Popen(["ls", "*00080"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output=p.communicate()[0] print "o", output result=commands.getoutput("ls *00080") print "o", result 给出了输出: o ls: can

只是想知道是否有人能告诉我原因

import subprocess, commands

p=subprocess.Popen(["ls", "*00080"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output=p.communicate()[0]
print "o", output
result=commands.getoutput("ls *00080")
print "o", result
给出了输出:

o ls: cannot access *00080: No such file or directory

o 010.010.013.165.42974-010.010.013.164.00080
两个人都应该找到文件,不是吗


一个

命令
spaws一个执行全局扩展的shell<除非传递
shell=True
,否则代码>子进程不会生成shell

换言之:

p=subprocess.Popen("ls *00080",shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
应该执行与
命令
相同的操作