Temporary file with specific file extension in Python 3 Temporary file with specific file extension in Python 3 python-3.x python-3.x

Temporary file with specific file extension in Python 3


This doesn't work for you?

In [2]: tempfile.NamedTemporaryFile(suffix='.tif').nameOut[2]: '/var/folders/gq/swc6jtld5853skyq_xc2lpc40000gn/T/tmplrtwvxg7.tif'


did you try?

fd, path =tempfile.mkstemp(suffix = '.tif')print(path)