Reputation: 13
the code gives error when I try to open directory as I want it to open the files within the directories however I am getting below error.
with open(i, 'rb') as f:
IsADirectoryError: [Errno 21] Is a directory: 'hard_signatures'
for i in SHA256_HASHES_pack1:
with open(i, 'rb') as f:
md5 = hashlib.md5()
sha1 = hashlib.sha1()
while True:
data = f.read(BUF_SIZE)
md5.update(data)
sha1.update(data)
if not data:
Upvotes: 0
Views: 30
Reputation: 618
That open
function opens a file
, not a directory
. See https://www.w3schools.com/python/ref_func_open.asp
If you want to cycle through all files in directory i
see How can I iterate over files in a given directory?
Upvotes: 1