03 2014 档案

摘要:对多个变量设置相同的值时,用连等号一起赋值x = 10y = 10z = 10改成:x = y = z = 10交换变量值时,可以避免定义新的临时变量x = 10y = 5temp = xx = yy = temp改成:x = 10y = 5x, y = y, x多次调用字符对象方法时,可以用链式调用方法,避免中间产生过多变量 str1 = 'i am a bug!'str2 = str1.strip()str3 = str2.upper()str4 = str3.replace('!', '?')改成:str4 = str1.strip().u 阅读全文
posted @ 2014-03-28 02:21 海鸟 阅读(1036) 评论(0) 推荐(0) 编辑
摘要:2006, 'MySQL server has gone away'描述:mysql服务端断开idle过期连接,而客户没有检测重连所以报错。解决:def is_connection_usable(): try: connection.connection.ping() except: return False else: return Truedef do_queue(): while True: if not is_connection_usable(): connection.close(... 阅读全文
posted @ 2014-03-01 23:30 海鸟 阅读(251) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示