open() mode args

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


On 2011年1月26日 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

AltStyle によって変換されたページ (->オリジナル) /