python终端模拟工具pexpect
pillow模块生成缩略图

mkstemp、mktemp、TemporaryFile区别

妙音 posted @ 2014年7月30日 13:07 in python , 4729 阅读

mkstemp

fd, name = tempfile.mkstemp 创建临时文件,并且将文件打开
>>> import tempfile
>>> tempfile.mkstemp()
(3, '/tmp/tmpkgWSR1')
查看/tmp目录,看到已经生成真实的文件
 
lsof查询打开的临时文件
[wyq@localhost tmp]$ lsof|grep tmp|grep python
python    8095           wyq    3u      REG               0,33         0     254593 /tmp/tmpkgWSR1
 
发现mkstemp不仅创建文件,而且将文件打开. 使用mkstemp很容易忘了这点,最终造成OSError: [Errno 24] Too many open files错误.
mkstemp返回的是文件描述和文件路径,并不常用,常用的是下面两个.

mktemp

name = tempfile.mktemp 返回一个临时文件的路径,但不创建该临时文件
>>> import tempfile
>>> tempfile.mktemp()
'/tmp/tmpPVidBM'
仅仅生成临时文件名

TemporaryFile

tempfile.TemporaryFile 返回文件对象(file-like)用于临时数据保存。当文件对象被close或者被del的时候,临时文件将从磁盘上删除
import time
with tempfile.TemporaryFile(mode='w+r') as f:
    f.write("=============")
    f.seek(0)
    print f.read()
    time.sleep(10)
TemporaryFile并未在/tmp目录中创建临时文件,应该只存在与内存中.
 
Avatar_small
依云 说:
2014年9月02日 14:16

TemporaryFile 在打开文件之后立即删除了文件,所以在文件系统中看不到。lsof 还是可以看到的:

4 REG 0x1f 0 17699285 /tmp/tmpvcndbo4q (deleted)

Avatar_small
Marijuana dispensary 说:
2020年11月05日 19:40

Organizing your immediate environment will make it easier for you to remember things! Keeping your keys, wallet, cell phone and other frequently used articles all together in the same place will prevent you from having to remember where they are. Since scent can improve memory, keep your favorite scented candle in this same central location! All of this will improve your memory and save you much stress and hassle.

Avatar_small
Where to buy banana 说:
2020年12月06日 04:39

I found so many interesting stuff in your blog especially its discussion. Really its great article. Keep it up. adding and subtracting mixed numbers

Avatar_small
no excuses runner 说:
2020年12月15日 16:25

I needed to thank you for this incredible read!! I unquestionably adored each and every piece of it. I have you bookmarked your site to look at the new stuff you post. pretty gaming

Avatar_small
Situs Judi Online Pk 说:
2020年12月19日 01:35

This is a great high resolution screen which you have shared for the users. Making a website is not an easy task but managing a good website is really a hard work. As far as this website is concerned, I am very happy. jovell price

Avatar_small
I definitely enjoyin 说:
2020年12月19日 20:24

When you use a genuine service, you will be able to provide instructions, share materials and choose the formatting style. download 918Kiss APK

Avatar_small
UBSE Question Paper 说:
2020年12月20日 15:05

Students going to appear for intermediate exams must download the UK board question paper of class 12 to prepare better. Students can also download question papers for all subjects in this article along with previous year papers. Solving UK board 12th question papers will aid students to ace the exam. The Uttarakhand 12th question papers will introduce students with exam pattern, marking scheme, types and number of questions asked and the difficulty level of the UK Board 12th exam. UK Board 12th question papers 2020-21 will be published on the official website after the exams. But students can solve previous years’ question papers along with UK 12th model papers 2021 to analyze their preparation level. Read the complete article to know more about UBSE Question Paper 2021 for 12th.

Avatar_small
먹튀검증업체 说:
2020年12月20日 17:43

Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! 먹튀검증업체

Avatar_small
Linus Pauling 说:
2020年12月21日 15:59

I havent any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. Linus Pauling

Avatar_small
Situs Judi Online Pk 说:
2020年12月22日 00:49

Hi - Visit this Informative Article for Wix vs squarespace 2020 | 10 Crucial Differences You Should Know

Avatar_small
penrose 说:
2020年12月22日 21:09

Most of the time I don’t make comments on websites, but I'd like to say that this article really forced me to do so. Really nice post! <a href="https://singaporepropertylaunch.com.sg/properties/penrose-condo/">penrose</a>

Avatar_small
penrose 说:
2020年12月22日 21:10

Most of the time I don’t make comments on websites, but I'd like to say that this article really forced me to do so. Really nice post! penrose

Avatar_small
Situs Judi Online Pk 说:
2020年12月24日 02:35

High Quality Toupees For Men human hair toupee sales - Honourhair

Avatar_small
Situs Judi Online Pk 说:
2020年12月25日 14:25

I know your aptitude on this. I should say we ought to have an online discourse on this. Composing just remarks will close the talk straight away! What's more, will confine the advantages from this data. بازی انفجار چگونه است

Avatar_small
visit Pussy888 offic 说:
2020年12月26日 16:02

I appreciate everything you have added to my knowledge base.Admiring the time and effort you put into your blog and detailed information you offer.Thanks. visit Pussy888 official website

Avatar_small
ryse residences cond 说:
2020年12月26日 18:47

Our credit repair services work to fix past credit mistakes and verify credit report accuracy. Talk to a credit repair expert today!  One Bernam Condo

Avatar_small
agen idn poker 说:
2020年12月29日 16:02

Hello There. I found your blog using msn. This is an extremely well written article. I will be sure to bookmark it and return to read more of your useful information. Thanks for the post. I’ll certainly comeback. agen idn poker

Avatar_small
no excuses runner 说:
2020年12月30日 21:27

I really loved reading your blog. It was very well authored and easy to undertand. Unlike additional blogs I have read which are really not tht good. I also found your posts very interesting. In fact after reading. I had to go show it to my friend and he ejoyed it as well! hidden wiki link

Avatar_small
mieszkania szczecin 说:
2020年12月31日 15:03

You’ve got some interesting points in this article. I would have never considered any of these if I didn’t come across this. Thanks!. mieszkania szczecin

Avatar_small
no excuses runner 说:
2020年12月31日 16:59

Your post has those facts which are not accessible from anywhere else. It’s my humble request to u please keep writing such remarkable articles kashan rugs for sale

Avatar_small
no excuses runner 说:
2020年12月31日 19:10

Great article with excellent idea!Thank you for such a valuable article. I really appreciate for this great information.. ดูอนิเมะ

Avatar_small
no excuses runner 说:
2020年12月31日 19:57

This article is an engaging abundance of enlightening information that is intriguing and elegantly composed. I praise your diligent work on this and thank you for this data. You have what it takes to get consideration. продать скины кс го

Avatar_small
no excuses runner 说:
2020年12月31日 20:51

One present why galore businesses opt for postcards is because they are overmuch cheaper to be prefab and this can forbear a lot of expenses on the lengthened run. 918 kiss apk

Avatar_small
no excuses runner 说:
2020年12月31日 21:25

One present why galore businesses opt for postcards is because they are overmuch cheaper to be prefab and this can forbear a lot of expenses on the lengthened run. forex signals

Avatar_small
AUSTRALIAN FAKE ID 说:
2021年1月02日 16:26

Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! AUSTRALIAN FAKE ID

Avatar_small
Betfair Bonus 说:
2021年1月04日 16:16

Yacht Rental Cyprus|Limos Cyprus|Yachts for hire Cyprus|Limousines Cyprus|Yacht excursions Cyprus|Boat Rental Cyprus | https://www.cyprusvipservice.com/ pays personal and professional attention to our respected clientele. We treat you as a VIP, just like you deserve. We ensure that you will enjoy your yacht or limo trip, to the fullest. Yachts for hire Cyprus

Avatar_small
free movies streamin 说:
2021年1月06日 21:06

Wow, cool post. I’d like to write like this too – taking time and real hard work to make a great article… but I put things off too much and never seem to get started. Thanks though. free movies streaming sites

Avatar_small
토토 说:
2021年1月07日 21:26

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. 토토

Avatar_small
Kişiye Özel 说:
2021年1月09日 18:59

This particular papers fabulous, and My spouse and i enjoy each of the perform that you have placed into this. I’m sure that you will be making a really useful place. I has been additionally pleased. Good perform! Kişiye Özel

Avatar_small
Kevin Galstyan 说:
2021年1月13日 16:12

It is a great website.. The Design looks very good.. Keep working like that!. Kevin Galstyan

Avatar_small
video projector outd 说:
2021年1月13日 21:19

Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject. video projector outdoor movie usa 2021

Avatar_small
php developers 说:
2021年1月16日 00:32

great...love reading your blog. <a href="https://www.phpworkplace.com/">php developers</a>

Avatar_small
먹튀검증 说:
2021年1月16日 14:20

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. 먹튀검증

Avatar_small
no excuses runner 说:
2021年1月20日 20:13

I found so many interesting stuff in your blog especially its discussion. Really its great article. Keep it up. 메이저사이트

Avatar_small
Faddy 说:
2021年1月24日 15:59

very interesting keep posting. 메이저사이트

Avatar_small
Faddy 说:
2021年1月25日 18:40

This was really an interesting topic and I kinda agree with what you have mentioned here! filmy wap

Avatar_small
Faddy 说:
2021年1月25日 21:51

Islamic Wall Art and Decor for the Modern Muslim Home Modern Islamic Canvas, Prints, and Framed Art for your home or as an Islamic Gift to family and friends. Top quality Islamic Wall Art made in USA and UK with FREE worldwide shipping islamic wall art

Avatar_small
no excuses runner 说:
2021年1月26日 20:02

A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up heimarbeit

Avatar_small
Faddy 说:
2021年1月27日 13:42

Excellent website! I adore how it is easy on my eyes it is. I am questioning how I might be notified whenever a new post has been made. Looking for more new updates. Have a great day! mastering biology

Avatar_small
lexmove.org 说:
2021年1月30日 05:25

Thank you very much for this great post. lexmove.org

Avatar_small
Faddy 说:
2021年1月30日 15:37

Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. Lavender Reed Diffuser

Avatar_small
no excuses runner 说:
2021年1月30日 17:13

You guardians do an astounding web diary, and have some unfathomable substance. Continue doing extraordinary. best auto policy mansfield

Avatar_small
Faddy 说:
2021年1月30日 18:31

I am continually amazed by the amount of information available on this subject. What you presented was well researched and well worded in order to get your stand on this across to all your readers. diamonds

Avatar_small
Faddy 说:
2021年2月02日 15:30

Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. Subzero refrigerator repair

Avatar_small
Faddy 说:
2021年2月02日 17:17

Very nice article, I enjoyed reading your post, very nice share, I want to twit this to my followers. Thanks!. Types of commercial roofing systems murfreesboro, TN

Avatar_small
no excuses runner 说:
2021年2月04日 20:11

I appreciate several from the Information which has been composed, and especially the remarks posted I will visit once more. phenq GNC offer

Avatar_small
no excuses runner 说:
2021年2月10日 17:02

Thanks for taking the time to discuss that, I feel strongly about this and so really like getting to know more on this kind of field. Do you mind updating your blog post with additional insight? It should be really useful for all of us. National Association of Pharmaceutical Representatives

Avatar_small
Faddy 说:
2021年2月17日 16:31

Your post is very helpful to get some effective tips to reduce weight properly. You have shared various nice photos of the same. I would like to thank you for sharing these tips. Surely I will try this at home. Keep updating more simple tips like this. 꽁머니

Avatar_small
no excuses runner 说:
2021年2月20日 20:58

Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place.. 먹튀검증사이트

Avatar_small
Waleed 说:
2021年2月28日 21:34

I want to say thanks for beautiful blog sharing with us. Your blog really great resource to update my knowledge. 메이저사이트

Avatar_small
JOHN 说:
2021年3月03日 21:30

Your post is very helpful to get some effective tips to reduce weight properly. You have shared various nice photos of the same. I would like to thank you for sharing these tips. Surely I will try this at home. Keep updating more simple tips like this. click here for more

Avatar_small
JOHN 说:
2021年3月09日 19:13

Thankyou for sharing the data which is beneficial for me and others likewise to see. เว็บพนันออนไลน์

Avatar_small
no excuses runner 说:
2021年3月16日 20:32

We are providing an Opportunity to make handsome amount of money by reselling our social media services on your own social media marketing or by selling them on Various Marketplace. cheap smm panel

Avatar_small
Weight Loss 说:
2021年3月17日 02:21

Recruitly is a cloud based Recruitment CRM and ATS system built to streamline agency recruitment processes and help businesses grow as a result. All the tools you need to run your recruitment business in one place. Visit our website to get more information. Thank You. Recruitment Software

Avatar_small
JOHN 说:
2021年3月18日 16:42

Your article is extremely helpful exceptionally fascinating subject i am looking that sort of post thank for imparting to us keep it up. สล็อต pg

Avatar_small
shah 说:
2021年3月19日 03:02

Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home. Bauunternehmung

Avatar_small
shah 说:
2021年3月21日 14:22

คาสิโนออนไลน์ บาคาร่ามือถือ 24 ชั่วโมง คาสิโน ฝาก ถอน ใน 1 นาที บาคาร่าออนไลน์ สล็อต สมัครวันนี้ รับเครดิตฟรี 200 line @casinoclub7 คาสิโนออนไลน์ไลน์เว็บตรง

Avatar_small
shah 说:
2021年3月21日 14:38

สล็อตออนไลน์ สล็อตออนไลน์ เรียกได้ว่าเป็นอีกหนึ่งเกมสล็อตที่ค่อนข้างนิยมอย่างมากในช่วงนี้นั่นก็เพราะว่าการเล่นสล็อตนั้นกูเป็นห่วงคาสิโนออนไลน์ที่เล่นง่ายที่สุดอีกทั้งยังมีตัวเกมมากมายให้เลือกซึ่งแน่นอนว่าขึ้นอยู่กับความชอบของผู้เล่นเองบอกได้เลยว่า ถือเป็นผู้ให้บริการทางด้านออนไลน์ที่สามารถมอบความสนุกสนานให้กับเหล่าบรรดาผู้เล่นได้เป็นอย่างดีที่สำคัญยังการันตีด้วยว่าสามารถเล่นได้อย่างง่ายดาย อีกทั้งยังการันตีด้วยว่ามีการจ่ายจริงไม่โกง ที่สำคัญเหล่าบรรดาลูกค้ายังสามารถทำการฝากถอนด้วยระบบอัตโนมัติตลอด 24 สล็อต

Avatar_small
shah 说:
2021年3月21日 15:12

บาคาร่า เว็บคาสิโนออนไลน์ บริการ 24 ชั่วโมง ฝากถอนไม่มีขั้นค่ำ บาคาร่าขั้นต่ำ 10 บาท เครดิตฟรีเว็บพนันออนไลน์ รับได้ทุกวัน บาคาร่าออนไลน์ บาคาร่าเครดิตฟรี

Avatar_small
shah 说:
2021年3月23日 16:03

Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. latest celebrity news

Avatar_small
shah 说:
2021年3月23日 18:46

Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. Crack streams

Avatar_small
shah 说:
2021年3月23日 21:40

If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. Instagram pva accounts

Avatar_small
shah 说:
2021年3月24日 16:30

I found that site very usefull and this survey is very cirious, I ' ve never seen a blog that demand a survey for this actions, very curious... แทงบอลขั้นต่ำ 10 บาท

Avatar_small
no excuses runner 说:
2021年3月25日 14:40

Healing crystal bracelets | Beaded Chakra Crystals | Enhanced Energy - Soul Charms Buy crystal bracelets for chakra balancing, reiki energy healing, meditation, yoga, stress, anxiety depression Personalized to your healing needs and intentions Crystal bracelets to attract abundance, luck, money, love, remove negativity, enhance psychic power, increase willpower, motivation, and more! crystal bracelets

Avatar_small
shah 说:
2021年3月25日 16:14

Thank you again for all the knowledge you distribute,Good post. I was very interested in the article, it's quite inspiring I should admit. I like visiting you site since I always come across interesting articles like this one.Great Job, I greatly appreciate that.Do Keep sharing! Regards, Carpet Cleaning services

Avatar_small
shah 说:
2021年3月25日 18:33

Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. 먹튀검증

Avatar_small
JOHN 说:
2021年4月01日 19:07

I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post. big gaming

Avatar_small
Dofollow Niche Blog 说:
2021年4月03日 20:56

When you use a genuine service, you will be able to provide instructions, share materials and choose the formatting style. Dofollow Niche Blog comments

Avatar_small
MOMII 说:
2021年7月08日 06:48 This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses. mulch delivery
Avatar_small
MOMII 说:
2021年7月08日 07:14

Pretty good post. I have just stumbled upon your blog and enjoyed reading your blog posts very much. I am looking for new posts to get more precious info. Big thanks for the useful info. https://orcid.org/0000-0002-9606-0555

Avatar_small
อุปกรณ์กล้องวงจรปิด 说:
2021年8月25日 12:26

It is somewhat fantastic, and yet check out the advice at this treat

Avatar_small
new zealand tourist 说:
2021年8月26日 04:32

Pretty good post. I have just stumbled upon your blog and enjoyed reading your blog posts very much. I am looking for new posts to get more precious info. Big thanks for the useful info.

Avatar_small
188bet 说:
2021年8月26日 08:30

There’s an adage in marketing, that if your target market is everybody, then nobody is going to be your customer. It’s easier to form waves during a pond than in an ocean For More Information.

Avatar_small
كود ايهيرب 说:
2021年8月28日 17:38

The most interesting text on this interesting topic that can be found on the net

Avatar_small
soap2da 说:
2021年8月31日 18:11

I have seen some great stuff here. Worth bookmarking for revisiting. I surprise how much effort you put to create such a great informative website. Your work is truly appreciated around the clock and the globe

Avatar_small
merchant sales rep 说:
2021年9月01日 00:09

This is really a nice and informative, containing all information and also has a great impact on the new technology. Thanks for sharing it,

Avatar_small
xeqt2k 说:
2021年9月03日 18:00

Thanks for the great info! <a href="https://voyance-telephone-gaia.com">voyance gratuite</a>

Avatar_small
xeqt2k 说:
2021年9月03日 18:00

[url=https://voyance-telephone-gaia.com]voyance gratuite[/url]

Avatar_small
Hammad Amir 说:
2021年9月05日 22:23

Thanks for your post. I’ve been thinking about writing a very comparable post over the last couple of weeks, I’ll probably keep it short and sweet and link to this instead if thats cool. Thanks. how to beat a drug charge

Avatar_small
suede fabric 说:
2021年9月09日 15:02

I haven't any word to value this post.....Really i am awed from this post....the individual who make this post it was an extraordinary human..thanks for imparted this to us.

Avatar_small
ท่อHDPE 说:
2021年9月15日 21:51

Cool you inscribe, the info is really salubrious further fascinating, I'll give you a connect to my scene.

Avatar_small
Hammad Amir 说:
2021年9月28日 18:24

Great survey, I'm sure you're getting a great response. Personal cyber guarantee

Avatar_small
t-shirts for nerds 说:
2021年9月29日 03:29

It is a great website.. The Design looks very good.. Keep working like that!

Avatar_small
dvd worldwide 说:
2021年10月02日 18:28

Nice to read your article! I am looking forward to sharing your adventures and experiences.

Avatar_small
Canada Visa Applicat 说:
2022年1月30日 07:00

It is a great website.. The Design looks very good.. Keep working like that!

Avatar_small
INDIA VISA ONLINE 说:
2022年2月04日 09:17

Nice to read your article! I am looking forward to sharing your adventures and experiences.

Avatar_small
child behavioral spe 说:
2022年4月12日 19:01

This is really a nice and informative, containing all information and also has a great impact on the new technology. Thanks for sharing it

Avatar_small
domnic doretto 说:
2022年5月10日 16:04

Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing. Keep blogging, <a href="https://timemasters.ca/">clock in clock out</a>

Avatar_small
domnic doretto 说:
2022年5月10日 16:22

thank you for a great post. <a href="https://timemasters.ca/">clock in clock out</a>

Avatar_small
Men's hair systems 说:
2022年5月26日 00:10

This content is simply exciting and creative. The article is very helpful. Getting a new hairstyle can be a way of looking at life a little differently, it can also change the way you’re feeling about yourself.
<a href="https://www.newtimeshair.com/mens-hair-systems/skin-hair-systems">thin skin hair systems, newtimeshair, men's hair systems, skin hair, systems wholesale, thin skin toupee, thin hair pieces</a> https://www.newtimeshair.com/mens-hair-systems/skin-hair-systems


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter