python:编写 XML 需要多少写访问权限
我正在编写一个将数据写入 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()
Gentoo OS 上的最终输出.xml 的大小为 422 字节。 Gentoo 的默认块大小是 1024 字节。我想知道这段代码会生成多少次磁盘写入(因为它取决于文件操作)。
谢谢你!
I am writing a python module that writes data into an XML file. The piece of code that handles the write is:
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()
The final output.xml has the size of 422 bytes onto Gentoo OS. Given the default blocksize of Gentoo is 1024 bytes. I am wondering how many writes to disk that piece of code would generate (since it's dependant on the file operation).
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在strace下运行程序就可以知道了。
Run the program under strace to find out.