

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a unique temporary file name using Python?
You can use the tempfile module to create a unique temporary file in the most secure manner possible. There are no race conditions in the file’s creation. The file is readable and writable only by the creating user ID. Note that the user of mkstemp() is responsible for deleting the temporary file when done with it. To create a new temporary file, use it as follows −
import tempfile _, temp_file_path = tempfile.mkstemp() print("File path: " + temp_file_path)
Note that you need to manually delete this file after you're done with it.
- Related Questions & Answers
- How to generate secure temporary file name using Python?
- How to create a temporary file using PowerShell?
- How to create a unique directory name using Python?
- Create a temporary file in Java
- How to create a tar file using Python?
- How to create a zip file using Python?
- How to delete a temporary file in Java?
- Program to make file names unique using Python
- How to create hardlink of a file using Python?
- How to create softlink of a file using Python?
- Create temporary file in specified directory in Java
- How to create a duplicate file of an existing file using Python?
- How to create an empty file using Python?
- Create temporary file with specified extension suffix in Java
- How to get the maximum file name length limit using Python?
Advertisements