0
mkstemp
によって開かれたハンドルを閉じるようにdef a
を変更したいと思います。しかし、私は失敗しました。私は窓にアナコンダパイソン2.7.13を使用どのようにtempfile.mkstempのハンドルを閉じるには?
import tempfile
import codecs
def a(json_content):
handle, file = tempfile.mkstemp(prefix="foobar-",suffix=".json")
write_to_file(json_content, file)
def write_to_file(text, filename):
with codecs.open(filename, 'w', 'utf-8', errors='ignore') as fp:
fp.write(unicode(text))
if __name__ == '__main__':
for i in range(50000):
a('{"foo":"bar", "iteration":%s}' %(i))
:
handle.close()
は、ハンドルがちょうどint
...
del handle
であるため、また、行動
MWEは変更されませんerrosにつながります(違いがある場合)
間違いなく重複します。くそー。私は検索しましたが、明らかに「ハンドル」は間違った用語でした – helt