随笔分类 -  python script

common functional tool
摘要:def test_variable_forin(): alist = ['a', 'bb', 'cc', 'dd'] count = 0 for i in alist: print i count += 1 if len(i) > 1: ... 阅读全文
posted @ 2013-02-20 16:49 道以万计 阅读(172) 评论(0) 推荐(0)
摘要:'''Created on Jan 28, 2013@author: changxue@summary: to look for a file by filename within specified directory, or look for some word in files'''import osimport sysdef search_file(key, scope): for parent, dirs, files in os.walk(scope): if key in files: print parent, ... 阅读全文
posted @ 2013-02-07 10:16 道以万计 阅读(394) 评论(0) 推荐(0)
摘要:'''Created on Feb 6, 2013@author: changxue@summary: to delete all files and directories in specified directory. print the name of file or directory if it can't remove.'''import os, sysdef clean(path): # to deal with abnormal situation if not os.path.exists(path): raise Ex 阅读全文
posted @ 2013-02-07 10:10 道以万计 阅读(250) 评论(0) 推荐(0)