python:编写 XML 需要多少写访问权限

发布于 2024-11-17 16:40:21 字数 438 浏览 3 评论 0原文

我正在编写一个将数据写入 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初相遇 2024-11-24 16:40:21

在strace下运行程序就可以知道了。

Run the program under strace to find out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文