吹
清理C盘临时文件
DEL /Q /F /S /A C:\Windows\Temp.
# 清除系统缓存 DEL /Q /F /S /A C:\Windows\Prefetch.
# 清理垃圾箱 DEL /Q /F /S /A C:\$Recycle.Bin.
# 清除系统日志 DEL /Q /F /S /A C:\Windows\Logs.
# 清理系统更新文件 DEL /Q /F /S /A C:\Windows\SoftwareDistribution.
# 清理旧系统驱动文件 DEL /Q /F /S /A C:\Windows\System32\DriverStore\FileRepository.
# 清理系统备份文件 DEL /Q /F /S /A C:\Windows\Backup.
蟒蛇 导入操作系统def clean_c_drive():
指定C盘路径
c_drive_path = 'C:\\' # 遍历C盘下所有文件和文件夹 对于 os.walk(c_drive_path) 中的 root、dirs、文件: 归档文件: file_path = os.path.join(根目录, 文件) #这里可以添加对文件类型的判断,比如清理临时文件等。 # 例如清理系统的临时文件夹: 如果 file_path.endswith('.tmp') 或 file_path.endswith('.tmp'): 尝试: os.remove(文件路径) print(f'已删除的文件: {file_path}') 排除异常为 e: print(f'删除文件失败:{file_path},错误信息:{e}') # 添加更多清理逻辑...<br># 调用函数 clean_c_drive()
注:此代码仅供参考。实际使用时,请根据需要修改清理逻辑,并在执行前做好备份,避免误删除重要文件。清理C盘系统文件需要谨慎。
重击
清理C盘临时文件
del /s /q /f /a c:\Windows\Temp.
清除系统缓存
del /s /q /f /a c:\Windows\Prefetch.
清除系统日志
del /s /q /f /a c:\Windows\Logs.
清理回收站
rmdir /s /q c:\$Recycle.Bin