开发者

python "r+" requires file to exist?

I know that it doesn't make sense to open file for reading if it doesn't exist, unlike for writing. But I need to create a file object, wr开发者_如何学Pythonite data to it and then read it later, that's why I want to use the "r+" mode. Of course I can just open the file for writing once and then open the saved file for reading, but the problem is I don't want the file to be saved to disc. Any ideas?


Maybe you should be using a StringIO then. It imitates file-like operations (such as writing to and reading from it).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜