File tree 1 file changed +7
-7
lines changed
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::
404
404
405
405
# create a temporary file using a context manager
406
406
# 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()
414
414
b'Hello world!'
415
415
>>>
416
416
# file is now removed
You can’t perform that action at this time.
0 commit comments