日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python rm 条件_删除文件 (rm)

發布時間:2025/1/21 python 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python rm 条件_删除文件 (rm) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

# 附錄A-練習14:刪除文件 (rm)

這節練習中,你將學會如何使用`rm`命令刪除一個文件。

### 做到這些

### Linux

~~~

$ cd temp

$ ls

uncool.txt iamcool.txt neat.txt something thefourthfile.txt

$ rm uncool.txt

$ ls

iamcool.txt neat.txt something thefourthfile.txt

$ rm iamcool.txt neat.txt thefourthfile.txt

$ ls

something

$ cp -r something newplace

$

$ rm something/awesome.txt

$ rmdir something

$ rm -rf newplace

$ ls

$

~~~

### Windows

~~~

> cd temp

> ls

Directory: C:\Users\zed\temp

Mode LastWriteTime Length Name

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

d---- 12/22/2011 4:52 PM newplace

d---- 12/22/2011 4:52 PM something

-a--- 12/22/2011 4:49 PM 0 iamcool.txt

-a--- 12/22/2011 4:49 PM 0 neat.txt

-a--- 12/22/2011 4:49 PM 0 thefourthfile.txt

-a--- 12/22/2011 4:49 PM 0 uncool.txt

> rm uncool.txt

> ls

Directory: C:\Users\zed\temp

Mode LastWriteTime Length Name

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

d---- 12/22/2011 4:52 PM newplace

d---- 12/22/2011 4:52 PM something

-a--- 12/22/2011 4:49 PM 0 iamcool.txt

-a--- 12/22/2011 4:49 PM 0 neat.txt

-a--- 12/22/2011 4:49 PM 0 thefourthfile.txt

> rm iamcool.txt

> rm neat.txt

> rm thefourthfile.txt

> ls

Directory: C:\Users\zed\temp

Mode LastWriteTime Length Name

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

d---- 12/22/2011 4:52 PM newplace

d---- 12/22/2011 4:52 PM something

> cp -r something newplace

> rm something/awesome.txt

> rmdir something

> rm -r newplace

> ls

>

~~~

### 你應該學到的

這里我們清理了之前練習中的所有文件。還記得我讓你嘗試使用`rmdir`刪除一個不為空的目錄嗎?那個操作失敗了因為你無法刪除包含文件在內的目錄。要做到這一點,你需要刪除文件,或者遞歸刪除所有的內容。這是你要在本節練習結尾要做的事情。

### 更多練習

> - 清理從開始練習到現在所有`temp`目錄下的文件。

> - 在你的筆記本上寫下遞歸刪除文件時一定要小心。

總結

以上是生活随笔為你收集整理的python rm 条件_删除文件 (rm)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。