五、python经典函数

 1.python2进行md5加密

import hashlib
def testMd5(string):
    m=hashlib.md5()
    m.update(string)
    n=m.hexdigest()
    print n

testMd5('123')
-------------------------
封装
import hashlib
class mytool():
    def testMd5(self,string):
        m=hashlib.md5()
        m.update(string)
        n=m.hexdigest()
        return n
        #print n
a=mytool()
a.testMd5('123456')
---------------------------------------------------------------------------------------------------------------------------------

猜你喜欢

转载自blog.csdn.net/chushujin/article/details/81279010