Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python make temp file

import tempfile
 
with tempfile.TemporaryFile() as tempf:
    tempf.write(b"Hello World!") # write to the tempf
    tempf.seek(0) # go to the first char of tempf
    print(tempf.read()) # prints b'Hello World!'
Comment

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")
Comment

PREVIOUS NEXT
Code Example
Python :: python parse args 
Python :: get file extension python 
Python :: dataframe show to semicolon python 
Python :: get object attributes python 
Python :: how to add numbers in python using for loop 
Python :: python ctypes get current window 
Python :: how to enable matplotlib in notebook 
Python :: install qt python 
Python :: pandas date_range 
Python :: .get python 
Python :: add rows to dataframe pandas 
Python :: easy sending email python 
Python :: python tkinter fullscreen 
Python :: python iterate object 
Python :: matplotlib set size 
Python :: python tkinter listbox click event 
Python :: django related_name abstract class 
Python :: python get keypressed value 
Python :: pandas display rows config 
Python :: asyncio wirte to text python 
Python :: talos get best model 
Python :: python list contains substring 
Python :: how to create a tkinter window 
Python :: how to take password using pyautogui 
Python :: double .get().get() dict python 
Python :: assert len(lex) < self.bucket_specs[-1][1] 
Python :: find record in mongodb with mongodb object id python 
Python :: random name generator in python 
Python :: python request post 
Python :: Python program to find Cumulative sum of a list 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =