2005年06月12日 星期日 13:31
ÈçÏÂ: from xml.dom.ext.reader.Sax2 import FromXmlStream doc=FromXmlStream(sys.stdin) ÔÚÕâÀïFromXmlStreamµÄ²ÎÊýʱsys.stdin£¬¼ÓÈëÎÒÓÐÒ»¸öxmlÎļþ£¬ÎļþÃûΪ test.xml£¬ ÎÒ¸ÃÈçºÎ°ÑÕâ¸ö sys.stdinÖØ¶¨Ïòµ½Õâ¸ötest.xmlÎļþÄØ£¿ ÄúÄܸø°ïÎÒдһ¸öÀý×Óô£¬¹ØÓÚÕâ¸östdinµÄ¶«Î÷ÎÒÒ»Ö±ºÜÄ£ºý£¬°üÀ¨C++ÖеÄÄÇÐ©Íæ Ò⣬ лл£¡
2005年06月12日 星期日 20:24
我想: f=file('test.xml') sys.stdin = f 不过为什么不直接: doc = FromXmlStream(f) 呢? 在 05-6-12,沂蒙山人<dreamingpython at 163.com> 写道: > 如下: > > from xml.dom.ext.reader.Sax2 import FromXmlStream > doc=FromXmlStream(sys.stdin) > > 在这里FromXmlStream的参数时sys.stdin,加入我有一个xml文件,文件名为 > test.xml, > 我该如何把这个 sys.stdin重定向到这个test.xml文件呢? > 您能给帮我写一个例子么,关于这个stdin的东西我一直很模糊,包括C++中的那些玩 > 意, > > 谢谢! > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > -- I like python! My Donews Blog: http://www.donews.net/limodou New Google Maillist: http://groups-beta.google.com/group/python-cn
2005年06月12日 星期日 22:42
沂蒙山人 wrote: > 如下: > > from xml.dom.ext.reader.Sax2 import FromXmlStream > doc=FromXmlStream(sys.stdin) > > 在这里FromXmlStream的参数时sys.stdin,加入我有一个xml文件,文件名为 > test.xml, > 我该如何把这个 sys.stdin重定向到这个test.xml文件呢? > 您能给帮我写一个例子么,关于这个stdin的东西我一直很模糊,包括C++中的那些玩 > 意, > > 谢谢! 方法1、改程序: doc = FromXmlStream(file('test.xml')) 方法2、修改sys.stdin: sys.stdin = file('test.xml') doc = FromXmlStream(sys.stdin) 方法3、shell重定向: python yourapp.py < test.xml -- Qiangning Hong __________________________________________________________ / When a camel flies, no one laughs if it doesn't get very \ \ far! / ---------------------------------------------------------- \ / \ //\ \ |\___/| / \// \\ /0 0 \__ / // | \ \ / / \/_/ // | \ \ @_^_@'/ \/_ // | \ \ //_^_/ \/_ // | \ \ ( //) | \/// | \ \ ( / /) _|_ / ) // | \ _\ ( // /) '/,_ _ _/ ( ; -. | _ _\.-~ .-~~~^-. (( / / )) ,-{ _ `-.|.-~-. .~ `. (( // / )) '/\ / ~-. _ .-~ .-~^-. \ (( /// )) `. { } / \ \ (( / )) .----~-.\ \-' .~ \ `. \^-. ///.----..> \ _ -~ `. ^-` ^-_ ///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~ /.-~
2005年06月13日 星期一 09:09
ÔÀ´ÕâÑù°¡£¬Ö»Òª½«Ò»¸öfile¶ÔÏó¸ºÖµ¸østdin¾Í¿ÉÒÔÁ˰¡£¬Ð»Ð»£¡Ð»Ð»£¡ "ÒÊÃÉɽÈË" <dreamingpython at 163.com> дÈëÓʼþ news:d8ggtc$qni$1 at sea.gmane.org... > ÈçÏÂ: > > from xml.dom.ext.reader.Sax2 import FromXmlStream > doc=FromXmlStream(sys.stdin) > > ÔÚÕâÀïFromXmlStreamµÄ²ÎÊýʱsys.stdin£¬¼ÓÈëÎÒÓÐÒ»¸öxmlÎļþ£¬ÎļþÃûΪ > test.xml£¬ > ÎÒ¸ÃÈçºÎ°ÑÕâ¸ö sys.stdinÖØ¶¨Ïòµ½Õâ¸ötest.xmlÎļþÄØ£¿ > ÄúÄܸø°ïÎÒдһ¸öÀý×Óô£¬¹ØÓÚÕâ¸östdinµÄ¶«Î÷ÎÒÒ»Ö±ºÜÄ£ºý£¬°üÀ¨C++ÖеÄÄÇÐ©Íæ > Ò⣬ > > лл£¡ > > >
Zeuux © 2025
京ICP备05028076号