Python子流程模块

Python子流程模块,python,subprocess,Python,Subprocess,我是python编程的初学者,在应用子流程模块的示例时,我遇到了一个错误 例如: #!/usr/bin/python import subprocess handle = subprocess. Popen("ls", stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) handle.stdout.read() 遇到的错误如下: AttributeError: 'mod

我是python编程的初学者,在应用子流程模块的示例时,我遇到了一个错误

例如:

#!/usr/bin/python

import subprocess

handle = subprocess. Popen("ls", stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
handle.stdout.read()
遇到的错误如下:

AttributeError: 'module' objecthas no attribute 'Popen'

提前谢谢

您可能将
.py
文件称为
subprocess.py


把它换成另一个名字。Python试图将您的文件作为
子进程导入

。Popen之间包含空格。波本

谢谢你的回答。
文件.py
称为
example.py
。该命令在python shell中正确执行,但保存在文件中时会出现此错误happens@PythonLover添加
打印子流程的输出。\u\u文件\u
对不起,我听不懂您的意思。我该怎么做