{"id":89,"description":"tempfile in Python","tags":["python","programming"],"contents":["Use tempfile.NamedTemporaryFile() callable to have a temporary file with a visible name","By default, file is opened in binary mode and is deleted on closing","Use \"w+\" to open in text mode.","Also works with context manager.","\u003e\u003e\u003e with tempfile.NamedTemporaryFile() as fp:","...     fp.write(b'Hello world!')","...     fp.seek(0)","...     fp.read()","b'Hello world!'"]}
