Python - How do I convert “an OS-level handle to an open file” to a file object?

后端 未结 6 1596
谎友^
谎友^ 2021-02-01 00:57

tempfile.mkstemp() returns:

a tuple containing an OS-level handle to an open file (as would be returned by os.open()) and the absolute pathname of that fi

6条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 01:10

    temp = tempfile.NamedTemporaryFile(delete=False)
    temp.file.write('foo\n')
    temp.close()
    

提交回复
热议问题