python tempfile.mkstemp() (创建临时文件)

def mkstemp(suffix=None, prefix=None, dir=None, text=False):
    """User-callable function to create and return a unique temporary
    file.  The return value is a pair (fd, name) where fd is the
    file descriptor returned by os.open, and name is the filename.

	用户调用的函数,用于创建并返回唯一的临时文件。 
	返回值是一对(fd,name),其中fd是os.open返回的文件描述符,name是文件名。

    If 'suffix' is not None, the file name will end with that suffix,
    otherwise there will be no suffix.

	如果“后缀”不为“无”,则文件名将以该后缀结尾,否则将没有后缀。

    If 'prefix' is not None, the file name will begin with that prefix,
    otherwise a default prefix is used.

	如果'prefix'不为None,则文件名将以该前缀开头,否则将使用默认前缀。
	
    If 'dir' is not None, the file will be created in that directory,
    otherwise a default directory is used.

	如果“ dir”不是None,则将在该目录中创建文件,否则将使用默认目录。

    If 'text' is specified and true, the file is opened in text
    mode.  Else (the default) the file is opened in binary mode.  On
    some operating systems, this makes no difference.

	如果指定了'text'且为true,则以文本模式打开文件。 
	否则(默认)该文件以二进制模式打开。 在某些操作系统上,这没有区别。

    If any of 'suffix', 'prefix' and 'dir' are not None, they must be the
    same type.  If they are bytes, the returned name will be bytes; str
    otherwise.

	如果“后缀”,“前缀”和“ dir”中的任何一个都不为None,则它们必须是同一类型。 
	如果它们是字节,则返回的名称将是字节; 否则为str。

    The file is readable and writable only by the creating user ID.
    If the operating system uses permission bits to indicate whether a
    file is executable, the file is executable by no one. The file
    descriptor is not inherited by children of this process.

	该文件只能由创建用户ID来读写。 
	如果操作系统使用权限位指示文件是否可执行,则该文件无人可执行。 
	该进程的子级不会继承文件描述符。

    Caller is responsible for deleting the file when done with it.

	完成后,调用方负责删除文件。(就是它自己不会自动删除)
    """

    prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)

    if text:
        flags = _text_openflags
    else:
        flags = _bin_openflags

    return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dontla

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值