storearea

导航

随笔分类 -  Python

Pyhon性能优化--日积月累
摘要:1. 减少函数调用次数num1 = 9if type(num1) == type(0): pass2这里调用了两次获取类型的函数。修改为:import typesif type(num1) == types.IntType: pass2. 对象身份比较性能高于值比较。import typ... 阅读全文

posted @ 2014-12-13 01:03 store 阅读(72) 评论(0) 推荐(0)

Python比较函数__cmp__
摘要:#!/usr/bin/pythonclass my_type(object): def __init__(self, v): self.value = v def __cmp__(self, v2): if self.value > v2.value: ... 阅读全文

posted @ 2014-12-12 22:26 store 阅读(266) 评论(0) 推荐(0)

Python中如何把一个UTC时间转换为本地时间
摘要:需求: 将20141126010101格式UTC时间转换为本地时间。 在网上搜了好长时间都没有找到完美的解决方案。有的引用了第三方库,这就需要在现网安装第三方的软件。这个是万万不可的。因为真实环境不一定允许你随便使用root用户安装Python模块。最终找到了一个不用外部模块的完美解决方案,放在... 阅读全文

posted @ 2014-11-26 22:36 store 阅读(811) 评论(0) 推荐(0)