当前位置:首页 » 编程语言 » 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')

热点内容
sqlserver数据库角色 发布:2025-03-18 18:59:22 浏览:272
家用威朗买哪个配置好 发布:2025-03-18 18:59:22 浏览:203
如何初始化路由器密码 发布:2025-03-18 18:44:23 浏览:974
ftp返回码 发布:2025-03-18 18:39:12 浏览:978
存储程序员里 发布:2025-03-18 18:39:08 浏览:16
如何用appleipad玩安卓游戏 发布:2025-03-18 18:21:54 浏览:33
录像机怎么配置光纤 发布:2025-03-18 18:20:19 浏览:630
全球最长锁屏密码是多少 发布:2025-03-18 18:18:51 浏览:219
服务器错误是自己电脑的问题吗 发布:2025-03-18 18:07:12 浏览:924
android开发编译 发布:2025-03-18 18:07:11 浏览:740