技术宅,fat-man

增加语言的了解程度可以避免写出愚蠢的代码

导航

2012年3月6日 #

python: bigint 和 time 互转

摘要: import timedef bigintToDateTime(d): return time.localtime(d)def dateTimeToBigint(d=None): if d==None: d=time.gmtime() return int(time.mktime(d))def stringToDateTime(s): return time.strptime(s, "%Y-%m-%d %H:%M:%S")def dateTimeToSting(d): if d==None: d=time.gmtime() ret... 阅读全文

posted @ 2012-03-06 16:59 codestyle 阅读(1104) 评论(0) 推荐(0)

代码的坏味道:控制结构嵌套太深

摘要: 重构前的代码 def newPrj(self,db,userId,prjName,password,privacy,intro='',status='active'): s = '' flag = False prjId=0 try: t = db.transaction() if privacy == 'public' and len(password) < 1: return '{"result":"error","message":"公开.. 阅读全文

posted @ 2012-03-06 09:43 codestyle 阅读(324) 评论(0) 推荐(0)