Created
August 28, 2021 18:46
-
-
Save kyanny/787de7ef15eaf7f414d36ac35dedacb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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