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

熱點內容
linux系統裝虛擬機 發布:2025-03-19 02:10:05 瀏覽:236
android自動解鎖 發布:2025-03-19 02:10:05 瀏覽:699
linuxforusbdevice 發布:2025-03-19 02:09:49 瀏覽:512
易達腳本 發布:2025-03-19 02:08:31 瀏覽:534
oracle給存儲過程授權 發布:2025-03-19 02:08:26 瀏覽:850
密碼M怎麼畫 發布:2025-03-19 02:03:41 瀏覽:109
java輸出到文件 發布:2025-03-19 01:49:07 瀏覽:432
光遇國際服安卓和蘋果如何互通 發布:2025-03-19 01:43:03 瀏覽:319
如何加密應用 發布:2025-03-19 01:42:04 瀏覽:620
lol伺服器人數怎麼擠 發布:2025-03-19 01:29:19 瀏覽:840