标签: python python-3.x temporary-files
在Python控制台中,我尝试创建t = tempfile.TemporaryFile(dir=d.name),d为TemporaryDirectory。问题是t中未创建d。
t = tempfile.TemporaryFile(dir=d.name)
d
TemporaryDirectory
t
d有一个名字,看起来都很好
t只是隐身,我可以t.write(b'hello')但无法在tempfile.gettempdir()找到该文件。
t.write(b'hello')
tempfile.gettempdir()