import tempfile
print(tempfile.gettempdir())
f = tempfile.TemporaryFile()
f.write('something on temporaryfile')
f.seek(0)
print(f.read())
f.close()
Cross-platform way of getting temp directory in Python