Latest web development tutorials

파이썬 os.tmpfile () 메소드

파이썬 파일 (파일) 방법 파이썬 OS 파일 / 디렉토리 방법


개요

os.tmpfile () 메소드 (+ B w) 오픈 모드 임시 파일 개체를 반환, 파일 폴더의 항목이없는이 개체는 어떤 파일 기술자는 자동으로 삭제되지 않습니다.

문법

다음과 같이TMPFILE () 메서드 구문은 다음과 같습니다

os.tmpfile

매개 변수

  • 아니

반환 값

임시 파일 오브젝트를 돌려줍니다.

다음은 사용 TMPFILE () 메서드를 보여줍니다

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os

# 创建临时文件对象
tmpfile = os.tmpfile()
tmpfile.write('临时文件在这创建了.....')
tmpfile.seek(0)

print tmpfile.read()
tmpfile.close

위 프로그램의 출력은 다음과 같습니다

临时文件在这创建了.....

파이썬 파일 (파일) 방법 파이썬 OS 파일 / 디렉토리 방법