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

熱點內容
問解壓 發布:2025-03-19 03:29:44 瀏覽:808
原神手機號如何修改賬號密碼 發布:2025-03-19 03:29:22 瀏覽:186
汽車配置哪些最省錢 發布:2025-03-19 03:10:16 瀏覽:517
如何讓自己伺服器ip不更換 發布:2025-03-19 03:05:07 瀏覽:231
存儲卡是怎麼製造的 發布:2025-03-19 02:57:15 瀏覽:491
怎麼設置區域網伺服器 發布:2025-03-19 02:54:25 瀏覽:338
php備份 發布:2025-03-19 02:54:11 瀏覽:645
如何把本機域名映射到伺服器上 發布:2025-03-19 02:44:20 瀏覽:24
如何連接非本地伺服器 發布:2025-03-19 02:44:17 瀏覽:573
泡泡堂伺服器地址 發布:2025-03-19 02:43:38 瀏覽:898