當前位置:首頁 » 編程語言 » 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命令行ftp 發布:2025-03-19 09:25:08 瀏覽:311
androideclipse的項目 發布:2025-03-19 09:25:03 瀏覽:110
php函數this 發布:2025-03-19 09:23:41 瀏覽:524
javalinux路徑 發布:2025-03-19 09:23:35 瀏覽:188
柴油乘用炮哪個配置性價比高 發布:2025-03-19 09:17:56 瀏覽:486
安卓如何取消鴻蒙升級提醒 發布:2025-03-19 09:17:04 瀏覽:621
清空本地緩存在哪 發布:2025-03-19 09:16:27 瀏覽:160
東方歸言錄日服賬號密碼如何設置 發布:2025-03-19 09:11:27 瀏覽:252
vue前台緩存組件 發布:2025-03-19 09:11:27 瀏覽:747
英雄聯盟手游用什麼安卓手機 發布:2025-03-19 08:59:58 瀏覽:933