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

熱點內容
yii資料庫配置文件 發布:2025-03-19 12:04:03 瀏覽:177
稅票網路配置怎麼填寫 發布:2025-03-19 12:02:39 瀏覽:473
三星的文件夾怎麼 發布:2025-03-19 12:01:07 瀏覽:818
安卓機如何生成wifi二維碼 發布:2025-03-19 12:00:22 瀏覽:833
字元串大寫php 發布:2025-03-19 11:47:02 瀏覽:955
紅白機rom反編譯 發布:2025-03-19 11:37:00 瀏覽:889
英特爾存儲盤的類型 發布:2025-03-19 11:35:36 瀏覽:920
linux修改svn 發布:2025-03-19 11:27:11 瀏覽:11
老爹起床鈴怎麼設置安卓 發布:2025-03-19 11:11:40 瀏覽:206
配置試劑的瓶子如何滅菌 發布:2025-03-19 11:07:16 瀏覽:603