From the course: Learning the Python 3 Standard Library
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Tempfile module - Python Tutorial
From the course: Learning the Python 3 Standard Library
Tempfile module
- [Instructor] We can use the Tempfile Module to create temporary files in Python, but in order to use the Tempfile Module, we have to import it. And so to import it, we'll go import tempfile. Now that we have access to it, we'll go ahead and create a temporary file. To do this, we'll create a variable. So tempFile, which will hold our temporary file that we create and then to create the temporary file we'll access the module, so tempfile., and then the temporary file constructor there, and that will create our temporary file. Now that our temporary file is stored inside a tempfile, we'll go ahead and access tempFile, and this is how we're going to write to the file. And so we'll go write, and what we're going to want to write to this temporary file is just a special number. And so we'll say Save this special number for me, it'll be 5678, and then 309. And this is your special number that you're saving. However, we're not…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.