File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -404,13 +404,13 @@ Here are some examples of typical usage of the :mod:`tempfile` module::
404404
405405 # create a temporary file using a context manager
406406 # close the file, use the name to open the file again
407- >>> with tempfile.TemporaryFile (delete_on_close=False) as fp:
408- ... fp.write(b'Hello world!')
409- ... fp.close()
410- # the file is closed, but not removed
411- # open the file again by using its name
412- ... with open(fp.name) as f
413- ... f.read()
407+ >>> with tempfile.NamedTemporaryFile (delete_on_close=False) as fp:
408+ ... fp.write(b'Hello world!')
409+ ... fp.close()
410+ ... # the file is closed, but not removed
411+ ... # open the file again by using its name
412+ ... with open(fp.name, mode='rb' ) as f:
413+ ... f.read()
414414 b'Hello world!'
415415 >>>
416416 # file is now removed
You can’t perform that action at this time.
0 commit comments