2013年2月20日
摘要:
md5(Message-Digest Algorithm 5) 模块用于计算信息密文(信息摘要),得出一个128位的密文。sha模块跟md5相似,但生成的是160位的签名。使用方法是相同的。如下实例是使用md5的:# /usr/bin/python# -*- coding:utf-8 -*-import base64try: import hashlib hash = hashlib.md5()except ImportError: # for Python << 2.5 import md5 hash = md5.new()hash.update('spam,s...
阅读全文
posted @ 2013-02-20 19:41
mingaixin
阅读(20004)
推荐(1)
摘要:
今天在学习python的md5模块的时候,做练习,遇到DeprecationWarning: the md5 module is deprecated; use hashlib instead import md5的警告;# /usr/bin/python# -*- coding:utf-8 -*-import md5hash = md5.new()hash.update('spam,spam,and egges')print repr(hash.digest())执行结果为:解决办法:# /usr/bin/python# -*- coding:utf-8 -*-try: im
阅读全文
posted @ 2013-02-20 16:09
mingaixin
阅读(5176)
推荐(0)
2013年2月19日
摘要:
在EditPlus里可以 自动换行 但是每次进入的时候都不会默认选中,觉得可能是个BUG,自动换行的状态没有保存在设置文件中,经过寻找在setting.ini里有记录:找到:将Word Wrap改为=1。自动换行:Word Wrap=1自动换行默认选中自动缩进:Auto Indent=0自动缩进默认不选==========================工具->参数->设置与语法->自动换行->选中,启动时自动换行快捷键在用editplus编辑时,遇到自动换行,使用ctrl+shift+w取消!
阅读全文
posted @ 2013-02-19 13:38
mingaixin
阅读(3643)
推荐(0)
摘要:
工具里的参数选项,然后弹出一个对话框,左边点文件,把保存文件时备份文件的选项取消,别勾选上,然后确定,就可以了
阅读全文
posted @ 2013-02-19 13:37
mingaixin
阅读(1010)
推荐(0)
2013年2月4日
摘要:
python的keywrod 模块很简单。Help on module keyword:NAME keyword - Keywords (from "graminit.c")FILE /usr/lib64/python2.6/keyword.pyDESCRIPTION This file is automatically generated; please don't muck it up! To update the symbols in this file, 'cd' to the top directory of the python sour
阅读全文
posted @ 2013-02-04 14:46
mingaixin
阅读(5981)
推荐(0)
2013年1月31日
摘要:
最近给项目加监控,用python写了一个脚本,在出错的时候自动发邮件通知的功能。代码如下#! /usr/bin/python# -*- coding: utf-8 -*- from smtplib import SMTPSMTPSVR='mail.xxx.com' #smtp服务器域名origHdrs=['From:monitor@xxx.com','To:cax@xxx.com,monitor@xxx.com','Subject:视频出现异常'] #定义邮件头origBody=['xxx','yyy
阅读全文
posted @ 2013-01-31 15:54
mingaixin
阅读(3785)
推荐(0)
摘要:
mro即 method resolution order (方法解释顺序),主要用于在多继承时判断属性的路径(来自于哪个类)。在python2.2版本中,算法基本思想是根据每个祖先类的继承结构,编译出一张列表,包括搜索到的类,按策略删除重复的。但是,在维护单调性方面失败过(顺序保存),所以从2.3版本,采用了新算法C3。为什么采用C3算法C3算法最早被提出是用于Lisp的,应用在Python中是为了解决原来基于深度优先搜索算法不满足本地优先级,和单调性的问题。本地优先级:指声明时父类的顺序,比如C(A,B),如果访问C类对象属性时,应该根据声明顺序,优先查找A类,然后再查找B类。单调性:如果在
阅读全文
posted @ 2013-01-31 15:41
mingaixin
阅读(5829)
推荐(2)
摘要:
python和C++一样,支持多继承。概念虽然容易,但是困难的工作是如果子类调用一个自身没有定义的属性,它是按照何种顺序去到父类寻找呢,尤其是众多父类中有多个都包含该同名属性。对经典类和新式类来说,属性的查找顺序是不同的。现在我们分别看一下经典类和新式类两种不同的表现:经典类:#! /usr/bin/python# -*- coding:utf-8 -*-class P1(): def foo(self): print 'p1-foo'class P2(): def foo(self): print 'p2-foo' def bar(self): ...
阅读全文
posted @ 2013-01-31 14:55
mingaixin
阅读(8727)
推荐(3)
posted @ 2013-01-31 11:27
mingaixin
阅读(520)
推荐(0)
摘要:
php手册: http://www.php.net/manual/zh/features.gc.refcounting-basics.php http://www.php.net/manual/zh/features.gc.collecting-cycles.php http://www.php.net/manual/zh/features.gc.performance-considerations.php
阅读全文
posted @ 2013-01-31 11:23
mingaixin
阅读(180)
推荐(0)