python中的无效参数错误

时间:2013-06-24 08:24:31

标签: python windows python-2.7

下面的python代码在我的Windows 7(32位)机器上运行。但它在Windows 7(64位)机器中显示以下错误,

proc.stdin.write('%d\n' % i)
invalid argument

代码:

import subprocess

print 'One line at a time:'
proc = subprocess.Popen('python repeater.py', 
                        shell=True,
                        stdin=subprocess.PIPE,
                        stdout=subprocess.PIPE,
                       )
for i in range(10):
    proc.stdin.write('%d\n' % i)
    output = proc.stdout.readline()
    print output.rstrip()
remainder = proc.communicate()[0]
print remainder

print
print 'All output at once:'
proc = subprocess.Popen('python repeater.py', 
                        shell=True,
                        stdin=subprocess.PIPE,
                        stdout=subprocess.PIPE,
                        )
for i in range(10):
    proc.stdin.write('%d\n' % i)

output = proc.communicate()[0]
print output

谢谢

0 个答案:

没有答案