Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import tempfile
with tempfile.NamedTemporaryFile() as tmp:
print(tmp.name)
tmp.write(b'Hello\nWorld')
tmp.seek(0)
with open(tmp.name) as f:
print(f.read())
with tempfile.NamedTemporaryFile(mode='w+t') as tmp:
print(tmp.name)
tmp.write('Hello\nWorld')
tmp.seek(0)
with open(tmp.name) as f:
print(f.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment