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

热点内容
lol服务器人数怎么挤 发布:2025-03-19 01:29:19 浏览:838
兄弟连的php 发布:2025-03-19 01:24:25 浏览:810
自己做脚本可不可以 发布:2025-03-19 01:20:13 浏览:533
33的源码值 发布:2025-03-19 01:13:25 浏览:814
虚荣安卓怎么充值 发布:2025-03-19 01:12:27 浏览:892
如何更改报考密码 发布:2025-03-19 01:08:12 浏览:416
python日期类型 发布:2025-03-19 01:02:28 浏览:415
android飞机大战源码 发布:2025-03-19 00:56:52 浏览:736
javaset方法 发布:2025-03-19 00:44:21 浏览:246
淘宝上传文件夹 发布:2025-03-19 00:36:30 浏览:73