2004年08月31日 星期二 16:57
我做如下实验: >>>import os >>>a=os.popen('cmd') >>>a.read() 'Microsoft Windows 2000 [Version 5.00.2195] (C) °?è¨?ùóD 1985-2000 Microsoft Corp. c:\>' >>>a.write('dir') Traceback (most recent call last): File "", line 1, in ? IOError: [Errno 9] Bad file descriptor >>>a=os.popen('python') >>>a.read() '' >>>a.write('print "ok"') Traceback (most recent call last): File "", line 1, in ? IOError: [Errno 9] Bad file descriptor 我无法通过管道下达命令,这是怎么回事?谢谢 ----- Original Message ----- From: "limodou" <chatme at 263.net> To: <python-chinese at lists.python.cn> Sent: Tuesday, August 31, 2004 3:57 PM Subject: Re: Re: [python-chinese] 关于不同程序间相互通讯的问题 > info,您好! > > 使用popen > > ======= 2004-08-31 15:49:32 您在来信中写道:======= > > >tocer,您好! > > > > socket,rpc > > > >======= 2004-08-31 15:45:04 您在来信中写道:======= > > > >>我想这样:先用主程序打开一个dos窗口,执行“python”,进入python的解释器内。然后主程序向解释器发送命令,比如help,print之类,解释器接受命令后执行。最后主程序把解释器的输出显示出来。 > >> > >>请问有什么好思路么? > >>谢谢 > >> > >> tocer_______________________________________________ > >>python-chinese list > >>python-chinese at lists.python.cn > >>http://python.cn/mailman/listinfo/python-chinese > >> > > > >= = = = = = = = = = = = = = = = = = = = > > > > > > 致 > >礼! > > > > > > info > > info at xichen.com > > 2004-08-31 > > > >_______________________________________________ > >python-chinese list > >python-chinese at lists.python.cn > >http://python.cn/mailman/listinfo/python-chinese > > > > = = = = = = = = = = = = = = = = = = = = > > > 致 > 礼! > > > limodou > chatme at 263.net > 2004-08-31 > > -------------------------------------------------------------------------------- > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese >
2004年08月31日 星期二 17:04
tocer,您好! 要仔细看文档,好象是使用popen2,支持输入和输出重定向的。popen只支持输出重定向。 ======= 2004-08-31 16:57:06 您在来信中写道:======= >我做如下实验: >>>>import os >>>>a=os.popen('cmd') >>>>a.read() >'Microsoft Windows 2000 [Version 5.00.2195] >(C) °?è¨?ùóD 1985-2000 Microsoft Corp. > >c:\>' >>>>a.write('dir') >Traceback (most recent call last): > File "", line 1, in ? >IOError: [Errno 9] Bad file descriptor > >>>>a=os.popen('python') >>>>a.read() >'' >>>>a.write('print "ok"') >Traceback (most recent call last): > File "", line 1, in ? >IOError: [Errno 9] Bad file descriptor > >我无法通过管道下达命令,这是怎么回事?谢谢 >----- Original Message ----- >From: "limodou" <chatme at 263.net> >To: <python-chinese at lists.python.cn> >Sent: Tuesday, August 31, 2004 3:57 PM >Subject: Re: Re: [python-chinese] 关于不同程序间相互通讯的问题 > > >> info,您好! >> >> 使用popen >> >> ======= 2004-08-31 15:49:32 您在来信中写道:======= >> >> >tocer,您好! >> > >> > socket,rpc >> > >> >======= 2004-08-31 15:45:04 您在来信中写道:======= >> > >> >>我想这样:先用主程序打开一个dos窗口,执行“python”,进入python的解释器内。然后主程序向解释器发送命令,比如help,print之类,解释器接受命令后执行。最后主程序把解释器的输出显示出来。 >> >> >> >>请问有什么好思路么? >> >>谢谢 >> >> >> >> tocer_______________________________________________ >> >>python-chinese list >> >>python-chinese at lists.python.cn >> >>http://python.cn/mailman/listinfo/python-chinese >> >> >> > >> >= = = = = = = = = = = = = = = = = = = = >> > >> > >> > 致 >> >礼! >> > >> > >> > info >> > info at xichen.com >> > 2004-08-31 >> > >> >_______________________________________________ >> >python-chinese list >> >python-chinese at lists.python.cn >> >http://python.cn/mailman/listinfo/python-chinese >> > >> >> = = = = = = = = = = = = = = = = = = = = >> >> >> 致 >> 礼! >> >> >> limodou >> chatme at 263.net >> 2004-08-31 >> >> > > >-------------------------------------------------------------------------------- > > >> _______________________________________________ >> python-chinese list >> python-chinese at lists.python.cn >> http://python.cn/mailman/listinfo/python-chinese >> _______________________________________________ >python-chinese list >python-chinese at lists.python.cn >http://python.cn/mailman/listinfo/python-chinese > = = = = = = = = = = = = = = = = = = = = 致 礼! limodou chatme at 263.net 2004-08-31
Zeuux © 2025
京ICP备05028076号