上一页 1 ··· 3 4 5 6 7
摘要: '''Created on Feb 7, 2013@author: changxue@summary: personal utils'''import os, time, shutil#current_time = time.strftime('%Y-%m-%d_%H%M', time.localtime(time.time()))current_time = time.strftime('%Y-%m-%d', time.localtime(time.time()))logfile = os.path.join(& 阅读全文
posted @ 2013-02-22 17:05 道以万计 阅读(675) 评论(0) 推荐(0) 编辑
摘要: '''Created on Feb 22, 2013@author: changxue@summary: aim: generate jar file path: 1. copy original jar to target dir 2. java t... 阅读全文
posted @ 2013-02-22 17:03 道以万计 阅读(1531) 评论(0) 推荐(0) 编辑
摘要: '''Created on Feb 22, 2013@author: changxue@summary: extract all archive files in src_dir into target_dir'''import os, shutil_list_postfix = ['.rar', '.zip', '.jar']tool_path = os.path.join(r'C:\Program Files\7-Zip')from common_util import _cre 阅读全文
posted @ 2013-02-22 17:01 道以万计 阅读(1817) 评论(0) 推荐(0) 编辑
摘要: python3: https://docs.python.org/3/library/csv.html 阅读全文
posted @ 2013-02-22 17:00 道以万计 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 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 道以万计 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 临时文件definition: import tempfile tempfile_name = tempfile.mktemp() # 创建名称唯一的临时文件供使用 temp1 = tempfile.TemporaryFile() # 注意:用TemporaryFile()创建的文件没有文件名 temp11= tempfile.TemporaryFile(mode='w+t') temp2 = tempfile.NamedTemporaryFile() # 尽管文件带有名字,但它仍然会在close后自动删除 temp... 阅读全文
posted @ 2013-02-07 10:37 道以万计 阅读(283) 评论(0) 推荐(0) 编辑
摘要: stdin: 0, stdout: 1, stderr: 2例2:(注cmd重定向进入后用exit返回原目录) cmd > file 把 stdout 重定向到 file 文件中 cmd >> file 把 stdout 重定向到 file 文件中(追加) cmd 1> file 把 stdout 重定向到 file 文件中 cmd > file 2>&1 把 stdout 和 stderr 一起重定向到 file 文件中 cmd 2> file 把 stderr 重定向到 file 文件中 cmd 2>> file 把 stder 阅读全文
posted @ 2013-02-07 10:30 道以万计 阅读(4046) 评论(0) 推荐(0) 编辑
摘要: summary:import timecur_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))一、小应用1.python获取当前时间time.time() 获取当前时间戳 1180759620.859time.localtime() 当前时间的struct_time形式 (2007, 6, 2, 12, 47, 7, 5, 153, 0)time.ctime() 当前时间的字符串形式 ’Sat Mar 28 22:24:24 2009′ISOTIMEFORMAT=’%Y-%m-%d %X 阅读全文
posted @ 2013-02-07 10:24 道以万计 阅读(161) 评论(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 道以万计 阅读(366) 评论(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 道以万计 阅读(242) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7