在 python 中制作 NamedTemporaryFile 时出现 ValueError
Getting a ValueError when making a NamedTemporaryFile in python
尚未通过搜索现有问题找到解决方案,这里是:
python 的新手。尝试使用 tempfile
包创建临时文件。这是失败的代码行 ValueError
:
(temp_file, self.bucket) = tempfile.NamedTemporaryFile(suffix='.py', prefix='Custom_', dir=[mydir], delete=False)
我在 运行 我的脚本时收到此 ValueError:
ValueError: need more than 0 values to unpack
为什么?
tempfile.NamedTemporaryFile()
没有 return 文件名,只有句柄。您需要访问名称属性才能获取文件名。
尚未通过搜索现有问题找到解决方案,这里是:
python 的新手。尝试使用 tempfile
包创建临时文件。这是失败的代码行 ValueError
:
(temp_file, self.bucket) = tempfile.NamedTemporaryFile(suffix='.py', prefix='Custom_', dir=[mydir], delete=False)
我在 运行 我的脚本时收到此 ValueError:
ValueError: need more than 0 values to unpack
为什么?
tempfile.NamedTemporaryFile()
没有 return 文件名,只有句柄。您需要访问名称属性才能获取文件名。