import hashlib import os src = "teststring" print hashlib.md5(src).hexdigest().upper() #hexdigest()为十六进制,digest为二进制