#coding=utf-8
import os
import glob
try:
#利用glob模块定位需要清理垃圾的模糊路径
File_1 = glob.glob("C:\Windows\SoftwareDistribution\DataStore\Logs\*.jrs")
for log in File_1:
if File_1 != 0:
try:
os.remove(log)
print "deleting redientsDataStore\Logs"
except OSError:
print "DataStore\Logs cant be removed"
File_2 = glob.glob("C:\Windows\WinSxS\ManifestCache\*.*")
for ManifestCache in File_2:
if File_2 != 0:
try:
os.remove(ManifestCache)
print "deleting WinSxS\ManifestCache"
except OSError:
print "WinSxS\ManifestCache cant be removed"
File_3 = glob.glob("C:\Windows\WinSxS\Backup\*.*")
for Backup in File_3:
if File_3 != 0:
try:
os.remove(Backup)
print "deleting WinSxS\Backup"
except OSError:
print "WinSxS\Backup cant be removed"
File_4 = glob.glob("C:\ProgramData\Microsoft\Windows Defender\Definition Updates\Backup\*.*")
for DefenderBackup in File_4:
if File_4 != 0:
try:
os.remove(DefenderBackup)
print "deleting Definition Updates\Backup下Defender"
except OSError:
print "Definition Updates\Backup cant be removed"
File_5 = glob.glob("C:\ProgramData\Microsoft\Windows Defender\Scans\*.*")
for Scans in File_5:
if File_5 != 0:
try:
os.remove(Scans)
print "deleting Windows Defender\Scans"
except OSError:
print "Windows Defender\Scans cant be removed"
File_6 = glob.glob("C:\Users\*\*\Local\Temp\NVIDIA Corporation\NV_Cache\*.*")
for NV_Cache in File_6:
if File_6 != 0:
try:
os.remove(NV_Cache)
print "deleting NVIDIA Corporation\NV_Cache"
except OSError:
print "NVIDIA Corporation\NV_Cache cant be removed"
# File_7=glob.glob("C:\Users\*\*\Local\Microsoft\Windows\Explorer\*.db")
# for Explorer in File_7:
# if File_7!=0:
# try:
# os.remove(Explorer)
# print "deleting Windows\Explorer"
# except OSError:
# print "Windows\Explorer cant be removed"
File_8 = glob.glob("C:\Windows\Temp\*.*")
for Temp in File_8:
if File_8 != 0:
try:
os.remove(Temp)
print "deleting Windows\Temp"
except OSError:
print "Windows\Temp cant be removed"
File_9 = glob.glob("C:\*\*\Local Settings\Temp\*.*")
for SettingTemp in File_9:
if File_9 != 0:
try:
os.remove(SettingTemp)
print "deleting Local Settings\Temp"
except OSError:
print "Local Settings\Temp cant be removed"
File_10 = glob.glob("C:\*\*\Local\TaoBrowser\User Data\Default\Cache\*.*")
for TaoBrowser in File_10:
if File_10 != 0:
try:
os.remove(TaoBrowser)
print "deleting TaoBrowser\User Data\Default\Cache"
except OSError:
print "TaoBrowser\User Data\Default\Cache cant be removed"
finally:
print "finally and enjoy"
raw_input()

  

【原创】python实现清理本地缓存垃圾的更多相关文章

  1. 安全清理Xcode 缓存垃圾

    安全清理Xcode缓存垃圾方法: 经验证,Xcode缓存垃圾存储在~/Library/Developer/Xcode/DerivedData/路径下,缓存和Xcode的版本有关(如同一台Mac安装2个 ...

  2. SQLite做为本地缓存的应用需要注意的地方

    原文:SQLite做为本地缓存的应用需要注意的地方 今天看到了园友陆敏计的一篇文章<<C#数据本地存储方案之SQLite>>, 写到了SQLite的诸多优点,尤其适应于本地数据 ...

  3. 亿级流量客户端缓存之Http缓存与本地缓存对比

    客户端缓存分为Http缓存和本地缓存,使用缓存好处很多,例如减少相同数据的重复传输,节省网络带宽资源缓解网络瓶颈,降低了对原始服务器的要求,避免出现过载,这样服务器可以更快响应其他的请求 Http缓存 ...

  4. iOS //清除本地缓存

    //清除本地缓存 -(void)clearCache{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT ...

  5. Android远程图片获取和本地缓存

    对于客户端——服务器端应用,从远程获取图片算是经常要用的一个功能,而图片资源往往会消耗比较大的流量,对 应用来说,如果处理不好这个问题,那会让用户很崩溃,不知不觉手机流量就用完了,等用户发现是你的应用 ...

  6. ImageLoader(多线程网络图片加载)+本地缓存 for windowsphone 7

    搞了好长一阵子wp,做点好事. C/S手机app中应用最多的是  获取网络图片,缓存到本地,展示图片 本次主要对其中的delay:LowProfileImageLoader进行修改,在获取图片的时候, ...

  7. 清理dns缓存

    dns缓存是什么? DNS缓存指DNS返回了正确的IP之后,系统就会将这个结果临时储存起来.并且它会为缓存设定一个失效时间 (例如N小时),在这N小时之内,当你再次访问这个网站时,系统就会直接从你电脑 ...

  8. 痞子衡嵌入式:第一本Git命令教程(7.1)- 清理之缓存(stash)

    今天是Git系列课程第七课,上一课我们学会了查看Git本地历史提交,今天痞子衡要讲的是Git仓库的清理操作,一共4个命令,都是日常开发中非常实用的命令,掌握这4个命令,会让你有一种玩弄Git仓库于股掌 ...

  9. Guava Cache 本地缓存组件浅析

    cache组件中核心的类和接口列举如下: 接口: Cache 本地缓存的顶级接口,提供一些对缓存进行get,put的方法,以及获取缓存统计数据的方法等. LoadingCache 继承了Cache接口 ...

随机推荐

  1. LeetCode 245. Shortest Word Distance III (最短单词距离之三) $

    This is a follow up of Shortest Word Distance. The only difference is now word1 could be the same as ...

  2. LeetCode 74. Search a 2D Matrix(搜索二维矩阵)

    Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...

  3. require.js实现js模块化编程(一)

    1.认识require.js: 官方文档:http://requirejs.org/RequireJS是一个非常小巧的JavaScript模块载入框架,是AMD规范最好的实现者之一.最新版本的Requ ...

  4. Zernike不变矩

    1.Zernike矩介绍 Zernike矩是基于 Zernike多项式的正交化函数,所利用的正交多项式集是 1个在单位圆内的完备正交集.Zernike矩是复数矩 ,一般把 Zernike矩的模作为特征 ...

  5. HDU6127Hard challenge

    Hard challenge Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) ...

  6. poj 3321Apple Tree

    Apple Tree Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit S ...

  7. 删除链表中等于给定值val的所有节点。

    样例 给出链表 1->2->3->3->4->5->3, 和 val = 3, 你需要返回删除3之后的链表:1->2->4->5. /** * D ...

  8. Azkaban安装部署

    在root的用户下搭建的 • Azkaban安装部署(可参照:http://azkaban.github.io/azkaban/docs/latest/) 1):前提 安装JDK,安装Hadoop,H ...

  9. HTML DOM应用案例2

    <html> <head> <title>day03</title> <script type="text/javascript&quo ...

  10. PHP读取数据库表显示到前台

    <?php$username=$_GET['uid']; //获取一个值作为查询条件 $result=$db->query("select * from trip where a ...