open() mode args

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Jan 26 11:53:23 EST 2011


On Wed, 26 Jan 2011 11:32:03 -0500, mpnordland wrote:

> What is the correct file mode to pass to open() when I want to both read
> and write on the open file?

open("filename", "r+") for text mode, "r+b" for binary mode. If your 
operating system does not distinguish between the two, you can use either.

More detail is available in the Fine Manual, or in the interactive help:

help(open)

at the Python prompt.

-- 
Steven



More information about the Python-list mailing list