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

热点内容
linuxfork进程 发布:2025-03-18 17:28:09 浏览:841
c远程桌面源码 发布:2025-03-18 17:26:20 浏览:244
brd源码 发布:2025-03-18 17:16:38 浏览:943
腾讯云使用代理服务器ip 发布:2025-03-18 17:14:19 浏览:897
顺丰同城骑士安卓苹果哪个抢单快 发布:2025-03-18 17:11:50 浏览:294
das直连存储 发布:2025-03-18 17:04:53 浏览:990
win7文件夹收藏 发布:2025-03-18 16:58:56 浏览:979
服务器地址区域华北和华南 发布:2025-03-18 16:52:17 浏览:874
用友的服务器如何卸载 发布:2025-03-18 16:51:25 浏览:730
tar打包文件夹 发布:2025-03-18 16:49:21 浏览:435