12 2012 档案
摘要:像if…else…这种没必要细说,Python中比C/C++多出来的有while…else…/for…else…/try…else…。while…else…/for…else…工作顺序为:在循环中使用时,else语句只在循环完成后执行,也就是说,break语句也会跳过else代码块,只要循环是正常结束,而不是通过break,else语句就会执行。try…else…功能和循环中的else语句没有多大区别:在try范围内没有检测到异常的时候,执行else子句。
阅读全文
摘要:在stackoverflow上看到的一篇,刚好解答了我的疑惑:http://stackoverflow.com/questions/68630/are-tuples-more-efficient-than-lists-in-python The "dis" module disassembles the byte code for a function and is usefu...
阅读全文
摘要:学习了下C#的排序,Array.Sort需要使用IComparer接口的比较函数。性能高,但是有时候需要写法简单不需要效率时,可以用LINQ: // To order a sequence by the values of the elements themselves, // specify the identity function (x => x) v.Ord...
阅读全文