首页 > 编程语言 > 详细

Python基础(一)文件处理

时间:2020-02-26 10:28:41      阅读:76      评论:0      收藏:0      [点我收藏+]
  1. xml
 1 from xml.dom.minidom import Document
 2 
 3 #文档根路径
 4 documentPath = E:\\ObjectOther\\Search\\PythonSearch\\document\\xml
 5 
 6 #xml 创建
 7 doc = Document()
 8 
 9 rootElement = doc.createElement(root)
10 doc.appendChild(rootElement)
11 
12 
13 node1 = doc.createElement(node1)
14 node1Text = doc.createTextNode(2222)
15 
16 node1.appendChild(node1Text)
17 rootElement.appendChild(node1)
18 
19 # 保存文件
20 with open(documentPath + \\1.xml, w, encoding=utf-8) as f:
21     doc.writexml(f, addindent=\t, newl=\n,encoding=utf-8)

参考:

https://blog.csdn.net/hu694028833/article/details/81089959

 

Python基础(一)文件处理

原文:https://www.cnblogs.com/loge/p/12365002.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!