import tempfile
temp = tempfile.TemporaryFile('w+')
print(temp)
#write to the file
temp.write("Hello world,")
temp.write("\nWelcome to Pynerds.")
#read from the file
temp.seek(0)
for i in temp.read():
print(i, end = '')
temp.close()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter