擅长:python、mysql、java
<p><code>mkstemp()</code>返回具有文件描述符和路径的元组。我认为问题是你的写作方向不对。(您正在写入类似<code>'(5, "/some/path")'</code>的路径。)您的代码应该如下所示:</p>
<pre><code>from tempfile import mkstemp
fd, path = mkstemp()
# use a context manager to open the file at that path and close it again
with open(path, 'w') as f:
f.write('TEST\n')
# close the file descriptor
os.close(fd)
</code></pre>