當前位置:首頁 » 編程語言 » 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')

熱點內容
c語言與程序設計大學教程 發布:2025-03-19 13:15:25 瀏覽:845
雲時客演算法 發布:2025-03-19 13:07:37 瀏覽:674
安卓如何使用icloud郵箱 發布:2025-03-19 13:00:19 瀏覽:58
c語言判斷是否是質數 發布:2025-03-19 12:38:13 瀏覽:898
未轉變者伺服器怎麼開 發布:2025-03-19 12:37:27 瀏覽:56
光纖服務管理密碼在哪裡 發布:2025-03-19 12:36:43 瀏覽:825
應用商店源碼 發布:2025-03-19 12:23:45 瀏覽:532
php寫模板 發布:2025-03-19 12:19:56 瀏覽:559
yii資料庫配置文件 發布:2025-03-19 12:04:03 瀏覽:179
稅票網路配置怎麼填寫 發布:2025-03-19 12:02:39 瀏覽:475