发现C盘空间不够用,检查了一下,发现Qt4的安装文件夹有些巨大,有1.4GB,进去一看,example文件夹有500MB,又发现大小主要由其工程中debug版本的可执行文件所决定,所以打算写一个脚本,把所有debug版本的生成文件删除,没想到这么简单的一个任务,因为长久不摸Python书,变得不是太简单,搞了半个多小时,终于大功告成,代码如下
[code:python]
def inter(dirname):
os.chdir(dirname)
pwd = os.getcwd()
for file in os.listdir(pwd):
nowfile = os.path.join(pwd, file)
if os.path.isdir(nowfile):
if file == 'debug':
os.chdir(nowfile)
os.system("move *.exe C:\\debug")
os.chdir('../')
print nowfile
else:
inter(nowfile)
if __name__ == '__main__':
import sys,os
if not os.path.isdir('C:\\debug'):
os.mkdir('C:\\debug')
inter('C:\\Qt\\4.4.3\\examples')
[/code]
然后到C盘下debug文件夹下查看,好家伙,500MB,被我全部删除,C盘空间就不紧张啦!
没有评论:
发表评论