初学Python,看起来跟Java格式非常相似啊,执行报错
本帖最后由 royzs 于 2014-10-13 10:45 编辑# cat test.py
#!/usr/bin/env python
import subprocess
cmd="cmd.exe"
begin=101
end=200
while begin<end:
p=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.PIPE)
p.stdin.write("ping 192.168.8."+str(begin)+"\n")
p.stdin.close()
p.wait()
print "execution result: %s"%p.stdout.read()执行的时候报错,不知道是哪里的问题 本帖最后由 royzs 于 2014-10-13 10:16 编辑
# ./test.py
execution result:
……
……
……
execution result:
Traceback (most recent call last):
File "./test.py", line 12, in <module>
p.stdin.write("ping 192.168.8."+str(begin)+"\n")
IOError: Broken pipe 太粗心了,原来是Windows平台的,如果在Linux平台下应该怎么改一下测试用呢,求助 菜鸟帮不上忙。
页:
[1]