Temporary file with specific file extension in Python 3

前端 未结 2 1403
盖世英雄少女心
盖世英雄少女心 2021-01-07 17:04

I am writing some unit tests for a piece of code that takes a path and attempts to load the file if it has a known extension, then does more careful checking.

In the

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-07 17:32

    This doesn't work for you?

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

提交回复
热议问题