{"id":3178,"date":"2023-03-18T09:56:15","date_gmt":"2023-03-18T01:56:15","guid":{"rendered":"http:\/\/192.168.31.200\/?p=3178"},"modified":"2023-03-18T09:56:15","modified_gmt":"2023-03-18T01:56:15","slug":"%e6%89%be%e5%87%ba%e6%8c%87%e5%ae%9a%e7%9b%98%e7%ac%a6%e8%b7%af%e5%be%84%e4%b8%8b%ef%bc%8c%e7%9b%b8%e5%90%8c%e5%a4%a7%e5%b0%8f%e5%90%8c%e5%90%8d%e6%88%96%e4%b8%8d%e5%90%8c%e5%90%8d%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"http:\/\/strawberry.ipyingshe.net:5347\/?p=3178","title":{"rendered":"\u627e\u51fa\u6307\u5b9a\u76d8\u7b26\u8def\u5f84\u4e0b\uff0c\u76f8\u540c\u5927\u5c0f\u540c\u540d\u6216\u4e0d\u540c\u540d\u6587\u4ef6"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>#\u627e\u51fa\u6307\u5b9a\u76d8\u7b26\u8def\u5f84\u4e0b\uff0c\u76f8\u540c\u5927\u5c0f\u540c\u540d\u6216\u4e0d\u540c\u540d\u6587\u4ef6\uff0cwin11\u3001python3.10.10\u73af\u5883\u8c03\u8bd5\u901a\u8fc7\r\nimport os, sys\r\n#\u5f15\u5165\u7edf\u8ba1\u6a21\u5757\r\nfrom stat import *\r\nBIG_FILE_THRESHOLD = 10000000  # \u4e0d\u9700\u8981\u52a0L\r\ndict1 = {}  # filesize \u505a key, filename \u505a value\r\ndict2 = {}   # filename \u505a key, filesize \u505a value\r\ndef treewalk(path):\r\n  try:\r\n    for entry in os.scandir(path): # \u4f7f\u7528os.scandir()\u51fd\u6570\r\n      if not entry.is_dir(): # \u4f7f\u7528is_dir()\u65b9\u6cd5\r\n        filename = entry.path # \u4f7f\u7528entry.path\u5c5e\u6027\r\n        filesize = entry.stat().st_size # \u4f7f\u7528entry.stat()\u65b9\u6cd5\r\n        if filesize > BIG_FILE_THRESHOLD:\r\n          if filesize in dict1:           \r\n            dict2&#91;filename] = filesize\r\n            dict2&#91;dict1&#91;filesize]]=filesize\r\n          else:\r\n            dict1&#91;filesize] = filename         \r\n      else:\r\n        treewalk(entry.path) # \u4f7f\u7528entry.path\u5c5e\u6027\r\n  except WindowsError:\r\n    pass\r\ndef printdict(finaldict):\r\n  for i_size in finaldict.values():\r\n    print(i_size)\r\n    for j_name in finaldict.keys():\r\n      if finaldict&#91;j_name] == i_size:\r\n        print(j_name)\r\n    print(\"\\n\")\r\nif __name__==\"__main__\":\r\n  treewalk(r\"e:\/\")\r\n  printdict(dict2)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,10],"tags":[],"class_list":["post-3178","post","type-post","status-publish","format-standard","hentry","category-2","category-python"],"_links":{"self":[{"href":"http:\/\/strawberry.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/strawberry.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/strawberry.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/strawberry.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/strawberry.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3178"}],"version-history":[{"count":1,"href":"http:\/\/strawberry.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3178\/revisions"}],"predecessor-version":[{"id":3179,"href":"http:\/\/strawberry.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3178\/revisions\/3179"}],"wp:attachment":[{"href":"http:\/\/strawberry.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/strawberry.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3178"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/strawberry.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}