Answer the question
In order to leave comments, you need to log in
How to create a temporary file and work with it in Python?
Hello. I am taking a course on Coursera, there is a task to create a temporary storage for storing data in json format. I wrote a script, everything works for me, I upload it to the server - it doesn't work, it gives an error:
Your script ended with an error FileNotFoundError: [Errno 2] No such file or directory: 'storage_path'
I read the documentation on the tempfile module, I didn't understand.
I create a file like this:
storage_path = os.path.join(tempfile.gettempdir(), 'storage.data')
with open(storage_path, mode='w', encoding='utf8') as file:
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question