2008年01月02日 星期三 14:31
´ó¼ÒºÃ£¬Ð¡µÜ¸Õѧpython£¬·Ç³£Ï²»¶ ÓÐÒ»¸öÎÊÌâÏëÎÊһϴó¼Ò ÎÒ´ÓÊý¾Ý¿âÖÐÈ¡³ö4¸ö×ֶΣ¬ÓÃ$·Ö¸îÿ¸ö×ֶΣ¬Éú³ÉÁËÒ»¸ötxtÎļþ ÏÖÔÚ£¬ÎÒÏëÒªÓÃpython£¬¶ÁÈ¡Õâ¸öÎļþ£¬²¢ÇÒ½«ÀïÃæµÄÄÚÈÝÉú³ÉÒ»¸öxmlÎļþ Îı¾ÎĵµÀý×ÓÈçÏ£º 1$a1$b1$c1 2$a2$b2$c2 Çë½ÌÒ»ÏÂÈçºÎ¶ÁÈ¡£¬È»ºóÉú³ÉxmlÎļþ ×îºÃÄܹ»¸øÒ»¸ö¼òµ¥µÄÀý×Ó Ð»Ð»´ó¼Ò -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20080102/36081afb/attachment.htm
2008年01月02日 星期三 14:34
Dive Into Python On Jan 2, 2008 2:31 PM, Yang Yang <scriptwolf在gmail.com> wrote: > ´ó¼ÒºÃ£¬Ð¡µÜ¸Õѧpython£¬·Ç³£Ï²»¶ > ÓÐÒ»¸öÎÊÌâÏëÎÊһϴó¼Ò > > ÎÒ´ÓÊý¾Ý¿âÖÐÈ¡³ö4¸ö×ֶΣ¬ÓÃ$·Ö¸îÿ¸ö×ֶΣ¬Éú³ÉÁËÒ»¸ötxtÎļþ > ÏÖÔÚ£¬ÎÒÏëÒªÓÃpython£¬¶ÁÈ¡Õâ¸öÎļþ£¬²¢ÇÒ½«ÀïÃæµÄÄÚÈÝÉú³ÉÒ»¸öxmlÎļþ > > Îı¾ÎĵµÀý×ÓÈçÏ£º > 1$a1$b1$c1 > 2$a2$b2$c2 > > Çë½ÌÒ»ÏÂÈçºÎ¶ÁÈ¡£¬È»ºóÉú³ÉxmlÎļþ > ×îºÃÄܹ»¸øÒ»¸ö¼òµ¥µÄÀý×Ó > > > лл´ó¼Ò > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -- --------------------------------------------------- www.douban.com/people/tutuqiang/ --------------------------------------------------- -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20080102/187cdf52/attachment.html
2008年01月02日 星期三 14:56
ÄãÏëÉú³ÉµÄXMLÎļþ¸ñʽÊÇʲôÑùµÄ£¿ ÄÇЩ×öAttribute£¬ÄÇЩ×öElement£¿ ÔÚ08-1-2£¬Tu Tu <tu.tuqiang在gmail.com> дµÀ£º > > Dive Into Python > > On Jan 2, 2008 2:31 PM, Yang Yang <scriptwolf在gmail.com> wrote: > > > ´ó¼ÒºÃ£¬Ð¡µÜ¸Õѧpython£¬·Ç³£Ï²»¶ > > ÓÐÒ»¸öÎÊÌâÏëÎÊһϴó¼Ò > > > > ÎÒ´ÓÊý¾Ý¿âÖÐÈ¡³ö4¸ö×ֶΣ¬ÓÃ$·Ö¸îÿ¸ö×ֶΣ¬Éú³ÉÁËÒ»¸ötxtÎļþ > > ÏÖÔÚ£¬ÎÒÏëÒªÓÃpython£¬¶ÁÈ¡Õâ¸öÎļþ£¬²¢ÇÒ½«ÀïÃæµÄÄÚÈÝÉú³ÉÒ»¸öxmlÎļþ > > > > Îı¾ÎĵµÀý×ÓÈçÏ£º > > 1$a1$b1$c1 > > 2$a2$b2$c2 > > > > Çë½ÌÒ»ÏÂÈçºÎ¶ÁÈ¡£¬È»ºóÉú³ÉxmlÎļþ > > ×îºÃÄܹ»¸øÒ»¸ö¼òµ¥µÄÀý×Ó > > > > > > лл´ó¼Ò > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > -- > --------------------------------------------------- > www.douban.com/people/tutuqiang/ > --------------------------------------------------- > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -- Èí¼þÒÔ³ÌÐòԱΪ±¾£¬³ÌÐòÔ±ÒÔ¼¼ÊõΪ±¾£¡ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20080102/14595bff/attachment.html
2008年01月02日 星期三 15:14
On Jan 2, 2008 2:31 PM, Yang Yang <scriptwolf在gmail.com> wrote: > 大家好,小弟刚学python,非常喜欢 > 有一个问题想问一下大家 > > 我从数据库中取出4个字段,用$分割每个字段,生成了一个txt文件 > 现在,我想要用python,读取这个文件,并且将里面的内容生成一个xml文件 > > 文本文档例子如下: > 1$a1$b1$c1 > 2$a2$b2$c2 > > 请教一下如何读取,然后生成xml文件 > 最好能够给一个简单的例子 txt = open('data.txt').read() xml = open('kidding.xml', 'w') print >>xml, "" print >>xml, "<[CDATA[" print >>xml, txt print >>xml, "]]> " xml.close() -- Qiangning Hong http://www.douban.com/people/hongqn/
2008年01月02日 星期三 15:16
ÀàËÆÕâÑùµÄ
2008年01月02日 星期三 15:39
有没有人研究过拼字符串和直接DOM操作哪个快,或者随attribute/node的数量变化有个什么曲线? On Jan 2, 2008 3:16 PM, Yang Yang <scriptwolf at gmail.com> wrote: > 类似这样的 > > >>
> 1 >a1 >b1 > > >> 2 >a2 >b2 > > > ... > > > > > 谢谢 > > 在08-1-2,Qutr <qutianrang at gmail.com> 写道: > > > 你想生成的XML文件格式是什么样的? > > 那些做Attribute,那些做Element? > > > > > > 在08-1-2,Tu Tu <tu.tuqiang at gmail.com> 写道: > > > > > > Dive Into Python > > > > > > On Jan 2, 2008 2:31 PM, Yang Yang <scriptwolf at gmail.com> wrote: > > > > > > > 大家好,小弟刚学python,非常喜欢 > > > > 有一个问题想问一下大家 > > > > > > > > 我从数据库中取出4个字段,用$分割每个字段,生成了一个txt文件 > > > > 现在,我想要用python,读取这个文件,并且将里面的内容生成一个xml文件 > > > > > > > > 文本文档例子如下: > > > > 1$a1$b1$c1 > > > > 2$a2$b2$c2 > > > > > > > > 请教一下如何读取,然后生成xml文件 > > > > 最好能够给一个简单的例子 > > > > > > > > > > > > 谢谢大家 > > > > > > > > _______________________________________________ > > > > python-chinese > > > > Post: send python-chinese at lists.python.cn > > > > Subscribe: send subscribe to python-chinese-request at lists.python.cn > > > > Unsubscribe: send unsubscribe to > > > > python-chinese-request at lists.python.cn > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > > > > > > -- > > > --------------------------------------------------- > > > www.douban.com/people/tutuqiang/ > > > --------------------------------------------------- > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese at lists.python.cn > > > Subscribe: send subscribe to python-chinese-request at lists.python.cn > > > Unsubscribe: send unsubscribe to > > > python-chinese-request at lists.python.cn > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > -- > > 软件以程序员为本,程序员以技术为本! > > _______________________________________________ > > python-chinese > > Post: send python-chinese at lists.python.cn > > Subscribe: send subscribe to python-chinese-request at lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -- >: ~ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20080102/e5321ae8/attachment.html
2008年01月02日 星期三 15:46
用ElementTree吧。详细用法见文档 在08-1-2,Yang Yang <scriptwolf at gmail.com> 写道: > > 类似这样的 > > >>
> 1 >a1 >b1 > > >> 2 >a2 >b2 > > > ... > > > > > 谢谢 > > 在08-1-2,Qutr <qutianrang at gmail.com> 写道: > > > > 你想生成的XML文件格式是什么样的? > > 那些做Attribute,那些做Element? > > > > > > 在08-1-2,Tu Tu <tu.tuqiang at gmail.com> 写道: > > > > > > Dive Into Python > > > > > > On Jan 2, 2008 2:31 PM, Yang Yang <scriptwolf at gmail.com> wrote: > > > > > > > 大家好,小弟刚学python,非常喜欢 > > > > 有一个问题想问一下大家 > > > > > > > > 我从数据库中取出4个字段,用$分割每个字段,生成了一个txt文件 > > > > 现在,我想要用python,读取这个文件,并且将里面的内容生成一个xml文件 > > > > > > > > 文本文档例子如下: > > > > 1$a1$b1$c1 > > > > 2$a2$b2$c2 > > > > > > > > 请教一下如何读取,然后生成xml文件 > > > > 最好能够给一个简单的例子 > > > > > > > > > > > > 谢谢大家 > > > > > > > > _______________________________________________ > > > > python-chinese > > > > Post: send python-chinese at lists.python.cn > > > > Subscribe: send subscribe to python-chinese-request at lists.python.cn > > > > Unsubscribe: send unsubscribe to > > > > python-chinese-request at lists.python.cn > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > > > > > > -- > > > --------------------------------------------------- > > > www.douban.com/people/tutuqiang/ > > > --------------------------------------------------- > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese at lists.python.cn > > > Subscribe: send subscribe to python-chinese-request at lists.python.cn > > > Unsubscribe: send unsubscribe to > > > python-chinese-request at lists.python.cn > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > -- > > 软件以程序员为本,程序员以技术为本! > > _______________________________________________ > > python-chinese > > Post: send python-chinese at lists.python.cn > > Subscribe: send subscribe to python-chinese-request at lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -- wayne -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20080102/0461e790/attachment.htm
2008年01月02日 星期三 16:12
On Jan 2, 2008 3:39 PM, Question <wanliyou在gmail.com> wrote: > 有没有人研究过拼字符串和直接DOM操作哪个快,或者随attribute/node的数量变化有个什么曲线? 显然是拼字符串快,操作DOM完了输出归根结底还是要拼字符串的 -- Qiangning Hong http://www.douban.com/people/hongqn/
Zeuux © 2024
京ICP备05028076号