python中temp是什么意思中文-python temp file:如何打开多次临时文件?

我正在尝试使用tempfile模块。(http://docs.python.org/2.7/library/tempfile.html)

我正在寻找一个临时文件,我可以打开几次,以获得几个流来读取它。tmp = ...

stream1 = # get a stream for the temp file

stream2 = # get another stream for the temp file

我尝试了几个函数(TemporaryFile、NamedTemporaryFile、SpooledTemporaryFile)并使用了fileno方法,但我无法执行所需的操作。

你知道我应该自己上课吗?

谢谢

>更新

试图打开名为的文件时出错。。。In [2]: t = tempfile.NamedTemporaryFile()

In [3]: t.write('abcdef'*1000000)

In [4]: t.name

Out[4]: 'c:\users\mike\appdata\local\temp\tmpczggbt'

In [5]: f = open(t.name)

---------------------------------------------------------------------------

IOError Traceback (most recent call last)

in ()

----> 1 f = open(t.name)

IOError: [Errno 13] Permission denied: 'c:\users\mike\appdata\local\temp\tmpczggbt'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值