以下は私のコードですが、達成しようとしているのはコードが機能するすべてのファイルのMD5ハッシュを生成しているOSですC:\からファイルを実行しようとすると、 "ioerror errno 13 permission denied: 'C:\ pagefile.sys'というタイトルのエラーが管理者として実行できますか?私が動作しない管理者としてcmdを実行しても、事前に感謝します。ioerror errno 13アクセスが拒否されました: 'C:\ pagefile.sys'
import os, hashlib
current_dir = os.getcwd()
for root,dirs,files in os.walk(current_dir):
for f in files:
current_file = os.path.join(root,f)
H = hashlib.md5()
with open(current_file) as FIN:
H.update(FIN.read())
with open("gethashes.txt", "a") as myfile:
myfile.write(current_file),myfile.write(", "),myfile.write(H.hexdigest()),myfile.write("\n")
print current_file, H.hexdigest()
ファイルが「ロックされていない場合」:http://stackoverflow.com/questions/19672352/how-to-run-python-script-with-elevated-privilege-on-windows – dsgdfg
* pagefile.sys *はスキップしました。あなたがそれを読むことができたとしても、内容はいつでも変更され、生成されたmd5ハッシュは間違っています。 –
@ J.J.Hakalaが言っていることに加えて、あなたがそれを読んでいるときに変わることさえあるかもしれません。 – Braiam