當前位置:首頁 » 編程語言 » python生成xml

python生成xml

發布時間: 2023-08-13 15:17:03

1. python生成xml,如何把頭寫成<xml version="1.0">

tree.write('createxml.xml',xml_declaration=True, encoding='utf-8', method="xml")

root = ET.Element('bookstore')
tree = ET.ElementTree()
tree._setroot(root)

child0 = ET.Element('book',{'category':"COOKING"})
root.append(child0)

child00 = ET.Element('title',{'language':"English"})
child00.text='Everyday Italian'
child0.append(child00)

tree.write('createxml.xml','utf-8')

熱點內容
蘋果6怎麼設置短密碼 發布:2025-03-19 04:44:41 瀏覽:17
三人樂隊怎麼配置 發布:2025-03-19 04:34:42 瀏覽:914
趣編程入口 發布:2025-03-19 04:25:09 瀏覽:939
a的存儲形式 發布:2025-03-19 04:24:00 瀏覽:789
android鍵盤修改 發布:2025-03-19 04:21:45 瀏覽:165
記錄體溫源碼 發布:2025-03-19 04:14:06 瀏覽:895
安卓電池充電次數怎麼查看 發布:2025-03-19 04:08:44 瀏覽:318
問解壓 發布:2025-03-19 03:29:44 瀏覽:811
原神手機號如何修改賬號密碼 發布:2025-03-19 03:29:22 瀏覽:188
汽車配置哪些最省錢 發布:2025-03-19 03:10:16 瀏覽:518