當前位置:首頁 » 編程語言 » 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 07:45:11 瀏覽:280
編譯原理概論實現文件讀寫 發布:2025-03-19 07:45:01 瀏覽:725
發微博python 發布:2025-03-19 07:44:19 瀏覽:420
農業銀行卡通常密碼是多少 發布:2025-03-19 07:44:14 瀏覽:734
演算法導論對數 發布:2025-03-19 07:30:58 瀏覽:145
sql字元串日期 發布:2025-03-19 07:30:52 瀏覽:731
編程求距離 發布:2025-03-19 07:30:52 瀏覽:980
win8無法訪問共享 發布:2025-03-19 07:30:49 瀏覽:29
個人電腦怎麼把伺服器放到公網 發布:2025-03-19 07:19:35 瀏覽:785
linux配置網路界面 發布:2025-03-19 07:10:10 瀏覽:900