2011年8月18日

python调用Shell脚本:os.system(cmd)或os.popen(cmd)()【转】

摘要: python调用Shell脚本,有两种方法:os.system(cmd)或os.popen(cmd),前者返回值是脚本的退出状态码,后者的返回值是脚本执行过程中的输出内容。实际使用时视需求情况而选择。 现假定有一个shell脚本test.sh: #!/bin/bash 1. echo "hello world!" 2. exit 3 os.system(cmd): 该方法在调用完shell脚本后,... 阅读全文

posted @ 2011-08-18 15:05 Cheney Shen 阅读(7344) 评论(0) 推荐(0) 编辑

2011年8月11日

字符串乘积运算+连接

摘要: node = ['160', 'd6', '1'] t5 = '0' * (3 - len(node[-3])) + node[-3] t4 = node[-2][0] + '0' * (4 - len(node[-2])) + node[-2][1:] print t5, t4 阅读全文

posted @ 2011-08-11 11:41 Cheney Shen 阅读(283) 评论(0) 推荐(0) 编辑

2011年8月10日

Python ,数字与字符,数字与字符串

摘要: 数字变为字符串 str() 字符串变为数字 string.atoi(s,[,base]) //base为进制基数 浮点数转换 string.atof(s) 需求: 需要把一个字符(ASCII或Unicode)转换为数字编码 ,或者反过来转换. 讨论: 对于ASCII字符,可以使用内建的ord和chr方法实现需求: >>> chr(97) 'a' >>> ord('a') 97 对于Unicode... 阅读全文

posted @ 2011-08-10 18:49 Cheney Shen 阅读(4171) 评论(0) 推荐(0) 编辑

python 快速排序代码

摘要: def quick_sort(ls): return [] if ls == [] else quick_sort([y for y in ls[1:] if y < ls[0]]) + [ls[0]] + quick_sort([y for y in ls[1:] if y >= ls[0]]) if __name__ == '__main__': l1 = [3,56,8,1,34,56,89... 阅读全文

posted @ 2011-08-10 18:31 Cheney Shen 阅读(201) 评论(0) 推荐(0) 编辑

2011年8月9日

文件夹拷贝,保留文件修改时间, 按修改时间最新排序

摘要: import sys, os, time, shutil from stat import ST_ATIME, ST_CTIME, ST_MTIME from win32file import CopyFile def test(self): remoteDir = "\\\\orc-fs\\Builds\\FP\\builds01\\flair\\Main" localDir = "d:\\... 阅读全文

posted @ 2011-08-09 19:36 Cheney Shen 阅读(1559) 评论(0) 推荐(0) 编辑

2011年8月8日

得到系统删除程序里的FIREFOX

摘要: from _winreg import * import re def subRegKey(key, patchlist): count = QueryInfoKey(key)[0] for index in range(count): name = EnumKey(key, index) result = patch.match(name) if result: patchlist.... 阅读全文

posted @ 2011-08-08 19:46 Cheney Shen 阅读(127) 评论(0) 推荐(0) 编辑

2011年8月7日

NSMutableArray,NSArray (From DFdou's Blog)

摘要: 首先,来看下2者的区别:NSArray and its subclass NSMutableArray manage collections of objects called arrays. NSArray creates static arrays, and NSMutableArray creates dynamic arrays.NSMutableArray是NSArray的子类,NSAr... 阅读全文

posted @ 2011-08-07 12:34 Cheney Shen 阅读(368) 评论(0) 推荐(0) 编辑

2011年8月6日

用NSBUNDLE自定义一个重复使用的TABLEVIEWCELL

摘要: ProductInfoTableViewCell *cell = (ProductInfoTableViewCell* )[tableView dequeueReusableCellWithIdentifier:kProductCellID]; //UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kProd... 阅读全文

posted @ 2011-08-06 20:41 Cheney Shen 阅读(303) 评论(0) 推荐(0) 编辑

iPhone delegate 两界面传递数据(转)

摘要: 在IOS里两个UIView窗口之间传递参数方法有很多,比如1.使用SharedApplication,定义一个变量来传递.2.使用文件,或者NSUserdefault来传递3.通过一个单例的class来传递4.通过Delegate来传递。前面3种方法,暂且不说,这次主要学习如何使用通过Delegate的方法来在不同的UIView里传递数据 。窗口1窗口2窗口2的结果传递给窗口11.首先定义个一委托... 阅读全文

posted @ 2011-08-06 20:33 Cheney Shen 阅读(730) 评论(0) 推荐(0) 编辑

NSLog打印当前文件,当前函数,当前行数

摘要: NSLog(@”%s, %s, %d”, __FILE__, __FUNCTION__, __LINE__); 阅读全文

posted @ 2011-08-06 20:02 Cheney Shen 阅读(455) 评论(0) 推荐(0) 编辑

导航