⬅︎ Back to To readline() or readlines()
Another useful way to read a file is the 'read()' function. I use it when I need a string to feed the md5.new() function.fileContent = open( fname,'r').read()# since I didn't assign the file object to a variable, it's closed after read. md5Object=md5.new( fileContent )theMD5 = md5Object.digest()This is useful if you are trying to find duplicate files (notably pictures) by their md5 checksum.Dan
Comment
Another useful way to read a file is the 'read()' function. I use it when I need a string to feed the md5.new() function.
fileContent = open( fname,'r').read()
# since I didn't assign the file object to a variable, it's closed after read.
md5Object=md5.new( fileContent )
theMD5 = md5Object.digest()
This is useful if you are trying to find duplicate files (notably pictures) by their md5 checksum.
Dan