import hashlib # m = hashlib.md5() # #print(m)#<built-in function openssl_md5> # m.update('hello'.encode('utf8')) # print(m.hexdigest())#5d41402abc4b2a76b9719d911017c592 def hashi(s):#定义一个加密函数,传一个字符串返回一个加密 m = hashlib.sha256()#sha256加密 m.update(s.encode('utf8')) #转UTF8 return m.hexdigest()#转16进制 a = 'liyou201711072230'#接收一个字符串 res = hashi(a)#调用函数 print(res)#打印结果