1. 程式人生 > >python 獲取文件md5

python 獲取文件md5

close () pytho os.path ash read def ret span

def GetFileMd5(filename):
    if not os.path.isfile(filename):
        return
    myhash = hashlib.md5()
    f = file(filename,rb)
    while True:
        b = f.read(8096)
        if not b :
            break
        myhash.update(b)
    f.close()
    return myhash.hexdigest()

python 獲取文件md5