here2share

# b_tempfile.py

Mar 30th, 2021 (edited)
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  1. # b_tempfile.py
  2.  
  3. import os
  4. import tempfile
  5.  
  6. fd, path = tempfile.mkstemp()
  7. try:
  8.     with os.fdopen(fd, 'w') as tmp:
  9.         # do stuff with temp file
  10.         tmp.write('stuff')
  11. finally:
  12.     os.remove(path)
Add Comment
Please, Sign In to add comment