当前位置:首页 » 编程语言 » 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-08-24 16:09:06 浏览:329
数据库的关系符号 发布:2025-08-24 16:02:29 浏览:625
sqlserver表值函数 发布:2025-08-24 15:56:27 浏览:553
linuxc内存泄露 发布:2025-08-24 15:54:30 浏览:111
python读取文件每一行 发布:2025-08-24 15:32:27 浏览:79
abbplc编程软件 发布:2025-08-24 15:31:43 浏览:206
苹果关闭密码如何设置新密码 发布:2025-08-24 14:28:41 浏览:298
安卓机安装包在哪里找 发布:2025-08-24 14:09:32 浏览:958
密码本时钟如何打开 发布:2025-08-24 13:45:48 浏览:721
安卓微信分身怎么弄 发布:2025-08-24 13:45:48 浏览:944