您当前的位置: 首页 >  Python

IT之一小佬

暂无认证

  • 4浏览

    0关注

    1192博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

python中tempfile库用法详解

IT之一小佬 发布时间:2022-08-21 23:53:19 ,浏览量:4

tempfile为内置库,不需要安装。

源码解读:

"""Temporary files.

This module provides generic, low- and high-level interfaces for
creating temporary files and directories.  All of the interfaces
provided by this module can be used without fear of race conditions
except for 'mktemp'.  'mktemp' is subject to race conditions and
should not be used; it is provided for backward compatibility only.

The default path names are returned as str.  If you supply bytes as
input, all return values will be in bytes.  Ex:

    >>> tempfile.mkstemp()
    (4, '/tmp/tmptpu9nin8')
    >>> tempfile.mkdtemp(suffix=b'')
    b'/tmp/tmppbi8f0hy'

This module also provides some data items to the user:

  TMP_MAX  - maximum number of names that will be tried before
             giving up.
  tempdir  - If this is set to a string before the first use of
             any routine from this module, it will be considered as
             another candidate location to store temporary files.
"""

参考博文:

Python临时文件创建:tempfile模块简介_嵌入式技术的博客-CSDN博客_python 临时文件

Python标准库tempfile的使用总结 - Wan-deuk-i - 博客园

https://www.jianshu.com/p/757bb5f9dc51

 python tempfile 创建临时目录

 Python3标准库:tempfile临时文件系统对象 - 走看看

关注
打赏
1665675218
查看更多评论
立即登录/注册

微信扫码登录

0.3184s