python遍歷文件夾并刪除特定格式文件的示例
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
def del_files(path):
for root , dirs, files in os.walk(path):
for name in files:
if name.endswith(".tmp"):
os.remove(os.path.join(root, name))
print ("Delete File: " + os.path.join(root, name))
# test
if __name__ == "__main__":
path = '/tmp'
del_files(path)
相關(guān)文章
Python實現(xiàn)輸出程序執(zhí)行進度百分比的方法
這篇文章主要介紹了Python實現(xiàn)輸出程序執(zhí)行進度百分比的方法,涉及Python數(shù)值運算與系統(tǒng)輸出相關(guān)操作技巧,需要的朋友可以參考下2017-09-09
Python基礎(chǔ)學(xué)習(xí)之奇異的GUI對話框
今天跨進了GUI編程的園地,才發(fā)現(xiàn)python語言是這么的好玩,文中對GUI對話框作了非常詳細的介紹,對正在學(xué)習(xí)python的小伙伴們有很好的幫助,需要的朋友可以參考下2021-05-05
Python使用plt庫實現(xiàn)繪制動態(tài)曲線圖并導(dǎo)出為GIF或MP4
這篇文章主要為大家詳細介紹了Python如何使用plt庫實現(xiàn)繪制動態(tài)曲線圖并導(dǎo)出為GIF或MP4,文中的示例代碼講解詳細,需要的可以了解一下2024-03-03

