tempfile创建临时文件或目录

import tempfile

tempfile.TemporaryFile()  # 创建文件,返回文件对象
tempfile.NamedTemporaryFile()  # 同上,不过会生成带有文件名的临时文件
tempfile.TemporaryDirectory()  # 生成临时目录
tempfile.gettempdir()  # 获取系统的临时目录。
tempfile.gettempdirb() # 与 gettempdir() 相同,只是该函数返回字节串。
tempfile.gettempprefix() #	返回用于生成临时文件的前缀名。
tempfile.gettempprefixb() #与 gettempprefix() 相同,只是该函数返回字节串
posted @ 2021-06-10 09:09  我在路上回头看  阅读(179)  评论(0编辑  收藏  举报