a guest Apr 20th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import os
- import tempfile
- file_descriptor, file_path = tempfile.mkstemp(suffix='.tmp')
- # You can convert the low level file_descriptor to a normal open file using fdopen
- with os.fdopen(file_descriptor, 'w') as open_file:
- # OR without the 'with'
- open_file = os.fdopen(file_descriptor, 'w')
- # OR without the open low level file_descriptor
- open_file = open(file_path, 'w')
- # You are responsibile for deleting your temp file
RAW Paste Data