简体   繁体   中英

Getting a ValueError when making a NamedTemporaryFile in python

haven't found a solution to this through searching existing questions, here goes:

New-ish to python. Trying to make a temporary file using the tempfile package. Here is the line of code that is failing with a ValueError :

(temp_file, self.bucket) = tempfile.NamedTemporaryFile(suffix='.py', prefix='Custom_', dir=[mydir], delete=False)

I'm getting this ValueError when I run my script:

ValueError: need more than 0 values to unpack

Why?

tempfile.NamedTemporaryFile() doesn't return the filename, only the handle. You need to access the name attribute in order to get the filename.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM