Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python create temp file

import tempfile
 
with tempfile.TemporaryFile() as fp:
    name = fp.name
    fp.write("Hello World!")  # Write a string using fp.write()
    content = fp.read()  # Read the contents using fp.read()
    print(f"Content of file {name}: {content}")
 
print("File is now deleted")
Source by www.askpython.com #
 
PREVIOUS NEXT
Tagged: #python #create #temp #file
ADD COMMENT
Topic
Name
8+3 =