直接将文件拖入命令行按Enter键,自动将md5复制到剪贴板。
先上图:
代码:
import hashlib
import os
import pyperclip
# 获取md5
def get_md5(file_path):
md5 = None
if os.path.isfile(file_path):
with open(file_path, 'rb') as f:
md5_obj = hashlib.md5()
md5_obj.update(f.read())
hash_code = md5_obj.hexdigest()
md5 = str(hash_code).lower()
return md5
while True:
path = input("File path:\n")
path.replace("\"","")
md5 = get_md5(path)
print(md5,"\n")
pyperclip.copy(md5)
注:需要pythonwin的支持
发表评论
抢沙发~