我正在编写一个将数据写入 XML 文件的 python 模块。处理写入的代码是:
from xml.dom.minidom import Document
#using DOMXml
main = Document() #create an XML Document
toFile = open('output.xml','w')
main.writexml(toFile, indent =' ', newl="\n")
#writexml() is the operation from Document that was imported
toFile.close()
最终的 output.xml 在 Gentoo OS 上的大小为 422 字节。给定 Gentoo 的默认块大小是 1024 字节。我想知道那段代码会生成多少次磁盘写入(因为它取决于文件操作)。
谢谢!