亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

利用python計算windows全盤文件md5值的腳本

系統(tǒng) 2012 0
            
import hashlib
import os
import time
import configparser
import uuid
 
def test_file_md5(file_path):
  test = hashlib.md5()
 
  if os.path.isfile(file_path):
    with open(file_path, "rb") as f:
      while True:
        data = f.read(8096)
        if not data:
          break
        else:
          test.update(data)
      ret = test.hexdigest()
      config = configparser.ConfigParser()
 
      config.read("E:/python/pycharm/再開次開始/前端/test_md5.ini",encoding="utf-8")
      if config.has_section(os.path.basename(file_path)):
        new_section_name = str(os.path.basename(file_path)) + ":" + str(uuid.uuid4())
        config[new_section_name] = {"文件路徑":os.path.dirname(file_path),
                 "md5值":ret}
      else:
        config[os.path.basename(file_path)] = {"文件路徑": os.path.dirname(file_path),
                        "md5值": ret}
      config.write(open("E:/python/pycharm/再開次開始/前端/test_md5.ini","w",encoding="utf-8"))
 
 
 
def test_dir_md5(file_path):
  test_abs_path = os.path.abspath(file_path)
  # print(test_abs_path)
  os.chdir(test_abs_path)
  for file in os.listdir(os.getcwd()):
    if os.path.isfile(file):
      test_file_md5(os.path.abspath(file))
    elif os.path.isdir(file):
      test_dir_md5(os.path.abspath(file))
    else:
      pass
  # return True
 
 
if __name__ == '__main__':
  began_path = os.getcwd()
  test_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(began_path))))
  os.chdir(test_path)
  print(os.listdir())
  for test_file in os.listdir():
    os.chdir(test_path)
    if os.path.abspath(test_file).startswith("E:\\$"):
      continue
    else:
      if os.path.isfile(test_file):
        # print("yyyyy")
        test_file_md5(os.path.abspath(test_file))
      elif os.path.isdir(test_file):
        # print("hahah")
        test_dir_md5(os.path.abspath(test_file))
        # print(os.path.abspath(test_file))
      else:
        pass
          

結(jié)果如下

利用python計算windows全盤文件md5值的腳本_第1張圖片

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。。?/p>

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 国产成人精品视频一区 | 女人十八毛片免费观 | 四虎影院入口 | 国产一区精品视频 | 麻豆视频一区 | 特级毛片免费视频播放 | a免费网站 | 91精品久久久 | 久久免费视频8 | 亚洲欧洲日韩在线 | 伊人色综合琪琪久久社区 | 亚洲精品一区二区三区婷婷月 | 久久精品99毛片免费 | 一级片 在线播放 | 中国一级一级全黄 | 91久久视频 | 两性影院| 一级寡妇乱色毛片全18 | 夜色伊人 | 欧美18videosex灌满 | 美国一级毛片片aa久久综合 | 99热精品在线 | 青青青精品免费视频 | 老司机性视频 | 国产做爰免费视频观看 | 高清视频在线播放 | 午夜精品影院 | 日本aaaa级| 99精品久久| 免费观看日本特色做爰视频在线 | 天天艹夜夜 | 黄色日本视频 | 国产精彩视频 | 伊人五月天综合 | 日韩精品午夜视频一区二区三区 | 久久狠色噜噜狠狠狠狠97 | 黄色毛片小视频 | 国产精品久久久久久久人热 | 狠狠色综合久久婷婷色天使 | 国产精品久久国产精品99 | 一级片a级片 |