我正在使用此代码计算文件的哈希值:
m = hashlib.md5()
with open("calculator.pdf", 'rb') as fh:
while True:
data = fh.read(8192)
if not data:
break
m.update(data)
hash_value = m.hexdigest()
print hash_value
Run Code Online (Sandbox Code Playgroud)
当我在文件夹"文件夹"上尝试时,我得到了
IOError: [Errno 13] Permission denied: folder
Run Code Online (Sandbox Code Playgroud)
我怎么能计算文件夹的哈希值?
我有一个文本文件,其中包含:
JavaScript 0
/AA 0
OpenAction 1
AcroForm 0
JBIG2Decode 0
RichMedia 0
Launch 0
Colors>2^24 0
uri 0
Run Code Online (Sandbox Code Playgroud)
我写了这段代码将文本文件转换为html:
contents = open("C:\\Users\\Suleiman JK\\Desktop\\Static_hash\\test","r")
with open("suleiman.html", "w") as e:
for lines in contents.readlines():
e.write(lines + "<br>\n")
Run Code Online (Sandbox Code Playgroud)
但是我在html文件中遇到的问题是在每一行中两列之间没有空格:
JavaScript 0
/AA 0
OpenAction 1
AcroForm 0
JBIG2Decode 0
RichMedia 0
Launch 0
Colors>2^24 0
uri 0
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能拥有相同的内容和文本文件中的两列
我有一个文件hash_db.pickle,当我创建它时,我在上面保存了一本字典:
v = {hash_value:{"file name":file_name,"file size":file_size,"last scanned time":scanned_time}}
{123dfre345:{"file name":calc.pdf,"file size":234,"last scanned time":12:23 24/12/2013}}
{3gcdshj754:{"file name":star.pdf,"file size":10,"last scanned time":10:30 10/10/2013}}
Run Code Online (Sandbox Code Playgroud)
last scanned time所以如果我只想从文件中更改3gcdshj754
我怎么能那样做呢?