Skip to main content
 首页 » 编程设计

python之Python 中有 FileIO 吗

2025年05月04日9mate10pro

我知道 Python 中有 StringIO 流,但是 Python 中有文件流这样的东西吗?我还有更好的方法来查找这些东西吗?文档等...

我正在尝试将“流”传递给我制作的“作家”对象。我希望我可以将文件句柄/流传递给这个编写器对象。

请您参考如下方法:

我猜您正在寻找 open()。 http://docs.python.org/library/functions.html#open

outfile = open("/path/to/file", "w") 
[...] 
outfile.write([...]) 

有关您可以使用流执行的所有操作的文档(这些在 Python 中称为“文件对象”或“类文件对象”):http://docs.python.org/library/stdtypes.html#file-objects