久久久精品网站,成人伊人网,色吧av色av,亚洲AV永久无码精品秋霞电影影院

臨時(shí)文件夾(臨時(shí)文件夾無(wú)寫(xiě)入權(quán)限,不能安裝)

前沿拓展:

臨時(shí)文件夾

微軟的WindowsXP一共有3個(gè)臨時(shí)文件夾

1.系統(tǒng)臨時(shí)文件夾

C盤(pán),Windows\Temp

2.計(jì)算機(jī)用戶(hù)帳戶(hù)臨時(shí)文件夾。C盤(pán),Documents and Settings\用戶(hù)名,一般是Administrator,\LocalSettings\Temp,系統(tǒng)默認(rèn)為隱藏目錄

3.IE瀏覽器臨時(shí)文件夾。C盤(pán),Documents and Settings\用戶(hù)名\Local Settings\Temporary internet File系統(tǒng)默認(rèn)隱藏文件


一、簡(jiǎn)介

這里介紹python中臨時(shí)文件及文件夾使用。使用的是tempfile包(安裝:pip install tempfile),參考地址是https://docs.python.org/3/library/tempfile.html。

二、臨時(shí)文件夾

2.1 獲取臨時(shí)文件夾

# 獲取臨時(shí)文件夾

tmpdir = tempfile.gettempdir()

print(tmpdir) #/tmp

2.2 生成臨時(shí)文件夾

# 方式一:生成默認(rèn)臨時(shí)文件夾

tmpdir = tempfile.mkdtemp()

print(tmpdir) #/tmp/tmpui77cgud

# 方式二:生成自定義臨時(shí)文件夾(指定前綴、后綴、目錄,可指定其中一部分),suffix:后綴, prefix:前綴, dir:目錄

tmpdir = tempfile.mkdtemp(suffix='_txt', prefix='tp_dir_', dir='/home/china/tmp/py_rs_file')

print(tmpdir) # /home/china/tmp/py_rs_file/tp_dir_06l_o2dm_txt

三、臨時(shí)文件

3.1 生成不自動(dòng)刪除(關(guān)閉時(shí))的臨時(shí)文件

# 方式一:生成默認(rèn)臨時(shí)文件,默認(rèn)為二進(jìn)制文件

tmpfile = tempfile.mkstemp()[1]

print(tempfile) #/tmp/tmp75kazf_8

# 數(shù)據(jù)寫(xiě)入

with open(tmpfile, 'w+') as t_f:

t_f.writelines('study hard and make progress')

# 方式二:生成自定義臨時(shí)文件(指定前綴、后綴、目錄、文件類(lèi)型參數(shù),可指定其中一部分),suffix:后綴, prefix:前綴, dir:目錄, text:文件類(lèi)型,True為文本,false為二進(jìn)制

tmpfile = tempfile.mkstemp(suffix='.txt', prefix='tp_', dir='/home/china/tmp/py_rs_file', text=True)[1]

print(tempfile) # /home/china/tmp/py_rs_file/tp_pn2973g0.txt

# 數(shù)據(jù)寫(xiě)入

with open(tmpfile, 'w+') as t_f:

t_f.writelines('study hard and make progress')

3.2 生成自動(dòng)刪除的臨時(shí)文件

# 方式一:創(chuàng)建臨時(shí)文件,文件關(guān)閉時(shí)自動(dòng)刪除

tmpfile = tempfile.TemporaryFile(mode='w+t')

tmpfile.write('study hard and make progress everyday') #數(shù)據(jù)寫(xiě)入

tmpfile.seek(0)

tmpTxt = tmpfile.read() #數(shù)據(jù)讀取

print(tmpTxt)

tmpfile.close() #關(guān)閉時(shí)文件自動(dòng)刪除

# 方式二:創(chuàng)建臨時(shí)文件,文件關(guān)閉時(shí)根據(jù)delete參數(shù)確定是否自動(dòng)刪除, True:刪除 False:不刪除

with tempfile.NamedTemporaryFile(delete=False) as tmpfile:

file_name = tmpfile.name

print(file_name) #/tmp/tmp73zl8gmn

tmpfile.write('study hard and make progress everyday'.encode())

tmpfile.seek(0)

tmpTxt = tmpfile.read().decode()

print(tmpTxt)

# 方式三:創(chuàng)建自定義臨時(shí)文件,文件關(guān)閉時(shí)可根據(jù)delete參數(shù)確定是否自動(dòng)刪除, True:刪除 False:不刪除

# 其他配置參數(shù)有,mode:文件模式(w+b為二進(jìn)制模式(默認(rèn)),w+t為文本模式),suffix:后綴, prefix:前綴, dir:目錄

with tempfile.NamedTemporaryFile(mode='w+t', suffix='.txt', prefix='tp_', dir='/home/china/tmp/py_rs_file',delete=False) as tmpfile:

file_name = tmpfile.name

print(file_name) #/home/china/tmp/py_rs_file/tp_fcwpmh3l.txt

tmpfile.write('study hard and make progress everyday')

tmpfile.seek(0)

tmpTxt = tmpfile.read()

print(tmpTxt)

拓展知識(shí):

臨時(shí)文件夾

工具/原料:電腦

1、第一在電腦中使用“windows+R組合鍵”進(jìn)入運(yùn)行中,輸入“temp”指令。

2、確定后就可進(jìn)入C盤(pán)中的temp臨時(shí)文件夾中,這里存放了系統(tǒng)運(yùn)行過(guò)程中**作的臨時(shí)文件。

3、點(diǎn)擊“修改時(shí)間”,按時(shí)間降序排列文件。

4、找到最新修改的文件,并將其**的電腦的桌面上。

5、對(duì)這個(gè)“tmp”后綴的文件重命名為“txt”后綴。

6、燃打開(kāi)就可以查看里面的內(nèi)容了。

原創(chuàng)文章,作者:九賢生活小編,如若轉(zhuǎn)載,請(qǐng)注明出處:http://xiesong.cn/40356.html

精品少妇精品| 国产成人综合视频| 日欧一级黄片| 欧美成www| 中文字幕黄色日韩电影| 亚洲国产另类久久久精品网站| 中文字幕 综合网| 婷亭五月| 久久中文无码精品| 欧美日韩国产人妖系列| 久久精品电影一区不卡| 欧美日韩一区二区综合| 亚洲a∨无码无在线观看| 欧美性猛交XXXX乱大交| 中文字幕一区二区不卡| 激情偷乱人伦| 无码中文幕国产精品| 美女自慰出水在线观看| 亚洲久热中文字幕在线| 久久夜色精品国产噜噜亚洲sv| 婷婷色国产精品视频一区| 被闺蜜的男人CAO翻了求饶| 亚洲av片一区二区三区| 91视频一区| 特级婬片免费放| 爱欲av.com| 一二三精品在线视频| 免费无码在线看| 欧美大胆一本| 日韩精品成人无码男| 久久激情网| 免费在线观看你懂的| 偷窥XXXX盗摄国产| 欧美亚洲网91| 久久久福利极品| 21p欧| 国产av电影网址| 成人片国产精品亚洲| 97中文字幕第一一一页| 亚洲女人被插入身体| 欧美日韩色色色|