擅长:python、mysql、java
<p>最初的海报是正确的,hashlib在python2.4中不可用,但是md5库是可用的。解决方法示例:</p>
<pre><code>try:
# Python 2.5 and up.
import hashlib
md5Hash = hashlib.md5
except ImportError:
# Python 2.4 and below.
import md5
md5Hash = md5.new
somedata = 'foobar'
hashstring = md5Hash (somedata).hexdigest ()
</code></pre>