2006年10月16日 星期一 12:54
On 10/16/06, Beinan Li <li.beinan在gmail.com> wrote: > > ¸Õ×°ÁËelementtree, ÔËÐиÿâÖ÷Ò³ÉÏÀý³Ì³ö´í, > > import elementtree.ElementTree as ET > # build a tree structure > root = ET.Element("html") > head = ET.SubElement(root, "head") > title = ET.SubElement(head, "title") > title.text = "Page Title" > body = ET.SubElement(root, "body") > body.set("bgcolor", "#ffffff") > body.text = "Hello, World!" > > # wrap it in an ElementTree instance, and save as XML > tree = ET.ElementTree(root) > tree.write("page.xhtml") > > ÒÔÏÂÊÇ´íÎóÐÅÏ¢: > IndexError: list index out of range > > Traceback (innermost last): > > File "i:\code\python\untitled-1.py", line 1, in ? > import time, sys, os, os.path, locale, fnmatch, winsound > File "i:\code\python\untitled-1.py", line 17, in ? > ET.ElementTree(root).write("test.html") [snip] > > ûÀíÓÉ°É.. > > µÄÈ·ÊÇûÀíÓÉ, ÎÒÔÚÎÒ»úÆ÷ÉÏÔËÐÐʲô´í¶¼Ã»ÓÐ ¿´ÄãµÄ³ö´ítraceback, ´úÂëºÃÏñºÍÀý×Ó²»Í¬, Òª²»°ÑÄã×Ô¼ºµÄ´úÂëÌùÉÏÀ´ -- simple is good http://brucewang.net -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20061016/5285cf10/attachment-0001.html
Zeuux © 2025
京ICP备05028076号