清空当前目录下,除本脚本文件的所有文本文件(点文件不在此列),清空当前目录,[Python]代码#!


[Python]代码

#!/usr/local/bin/python2import osfiles = os.listdir(os.getcwd())for one_file in files:    if os.path.isfile(one_file) and one_file != os.path.basename(__file__):        (open(one_file, 'w')).truncate()print "Done!"

评论关闭