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

热点内容
c语言取随机数 发布:2025-02-06 02:46:57 浏览:863
uc缓存的视频卡住 发布:2025-02-06 02:17:05 浏览:144
解压同学介绍 发布:2025-02-06 02:13:10 浏览:776
icsftp 发布:2025-02-06 02:12:59 浏览:325
ftp跨域上传文件 发布:2025-02-06 02:09:22 浏览:822
非递归全排列算法 发布:2025-02-06 02:06:45 浏览:551
vs反编译dll 发布:2025-02-06 02:06:00 浏览:584
ubuntu设置ftp权限 发布:2025-02-06 01:54:07 浏览:599
奇瑞5哪个配置值得买 发布:2025-02-06 01:51:56 浏览:552
黑鲨手机哪里看安卓版本 发布:2025-02-06 01:36:04 浏览:803