Python删除windows垃圾文件的方法
本文实例讲述了Python删除windows垃圾文件的方法。分享给大家供大家参考。具体如下:
#coding:utf-8 import os #from glob import glob if os.name == 'nt': if 'HOMEPATH' in os.environ: home = os.environ['HOMEDRIVE'] + os.environ['HOMEPATH'] else: home = os.environ['HOMEPATH'] workpath = os.path.join(home,'Local Settings') #递归删除文件 #里面和下面的函数用try是抛出删除正在使用的零时文件出错 def delfile(path): for file in os.listdir(path): if os.path.isfile(os.path.join(path,file)): try: print "\n删除垃圾文件: %s" % (os.path.join(path,file)) os.remove(os.path.join(path,file)) except: pass elif os.path.isdir(os.path.join(path,file)): delfile(os.path.join(path,file)) else: pass delfile(os.path.join(workpath,'Temp')) delfile(os.path.join(workpath,'Temporary Internet Files')) #删除文件家的时候必须为空文件夹,而且只能从最里层删起 def deldir(pa): for i in os.listdir(pa): if os.path.isdir(os.path.join(pa,i)): if len(os.listdir(os.path.join(pa,i))) > 0: deldir(os.path.join(pa,i)) try: os.rmdir(os.path.join(pa,i)) except: pass else: try: print "\n删除文件夹 %s" % (os.path.join(pa,i)) os.rmdir(os.path.join(pa,i)) except: pass deldir(os.path.join(workpath,'Temp')) deldir(os.path.join(workpath,'Temporary Internet Files')) print """ 系统产生的零时垃圾文件清理完毕! """ raw_input("请按回车键退出!")
希望本文所述对大家的Python程序设计有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The H5 page needs to be maintained continuously, because of factors such as code vulnerabilities, browser compatibility, performance optimization, security updates and user experience improvements. Effective maintenance methods include establishing a complete testing system, using version control tools, regularly monitoring page performance, collecting user feedback and formulating maintenance plans.

How to implement Windows-like in front-end development...

PS "Loading" problems are caused by resource access or processing problems: hard disk reading speed is slow or bad: Use CrystalDiskInfo to check the hard disk health and replace the problematic hard disk. Insufficient memory: Upgrade memory to meet PS's needs for high-resolution images and complex layer processing. Graphics card drivers are outdated or corrupted: Update the drivers to optimize communication between the PS and the graphics card. File paths are too long or file names have special characters: use short paths and avoid special characters. PS's own problem: Reinstall or repair the PS installer.

A PS stuck on "Loading" when booting can be caused by various reasons: Disable corrupt or conflicting plugins. Delete or rename a corrupted configuration file. Close unnecessary programs or upgrade memory to avoid insufficient memory. Upgrade to a solid-state drive to speed up hard drive reading. Reinstalling PS to repair corrupt system files or installation package issues. View error information during the startup process of error log analysis.

Solving the problem of slow Photoshop startup requires a multi-pronged approach, including: upgrading hardware (memory, solid-state drive, CPU); uninstalling outdated or incompatible plug-ins; cleaning up system garbage and excessive background programs regularly; closing irrelevant programs with caution; avoiding opening a large number of files during startup.

PS card is "Loading"? Solutions include: checking the computer configuration (memory, hard disk, processor), cleaning hard disk fragmentation, updating the graphics card driver, adjusting PS settings, reinstalling PS, and developing good programming habits.

H5 is more flexible and customizable, but requires skilled technology; mini programs are quick to get started and easy to maintain, but are limited by the WeChat framework.

The reason for slow PS loading is the combined impact of hardware (CPU, memory, hard disk, graphics card) and software (system, background program). Solutions include: upgrading hardware (especially replacing solid-state drives), optimizing software (cleaning up system garbage, updating drivers, checking PS settings), and processing PS files. Regular computer maintenance can also help improve PS running speed.
