{"id":2575,"date":"2024-03-20T00:33:19","date_gmt":"2024-03-19T16:33:19","guid":{"rendered":"http:\/\/www.ccwifi.cc\/blogs\/?p=2575"},"modified":"2024-03-20T00:33:19","modified_gmt":"2024-03-19T16:33:19","slug":"python%e5%ae%9e%e7%94%a8%e6%a1%88%e4%be%8bpython%e8%84%9a%e6%9c%ac8521","status":"publish","type":"post","link":"https:\/\/www.ccwifi.cc\/blogs\/2024\/03\/20\/python%e5%ae%9e%e7%94%a8%e6%a1%88%e4%be%8bpython%e8%84%9a%e6%9c%ac8521\/","title":{"rendered":"Python\u5b9e\u7528\u6848\u4f8b\uff0cPython\u811a\u672c\uff0cPython\u5b9e\u73b0\u7834\u8bd1zip\u538b\u7f29\u5305"},"content":{"rendered":"<div>\n<p>\u5728\u7ebfwifi\u8dd1\u5305 \u91d1\u521a\u5305\u8dd1\u5305 cap\u8dd1\u5305 hccapx ewsa\u5728\u7ebf \u5c31\u6765 <strong><a href=\"https:\/\/ccwifi.cc\" target=\"_blank\" rel=\"noopener\">\u63e1\u624b\u5305\u8dd1\u5305<\/a><\/strong><\/p>\n<p>\u5404\u4f4d\u597d \u53c8\u89c1\u9762\u4e86 \u6211\u662f\u66f9\u64cd \u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u7bc7\u65b0\u7684\u6559\u7a0b<\/p>\n<p>\u5e0c\u671b\u5404\u4f4d\u7ec6\u5fc3\u5b66\u4e60 \u4f4e\u8c03\u7528\u7f51<\/p>\n<\/div>\n<p><img decoding=\"async\" src=\"http:\/\/www.ccwifi.cc\/blogs\/wp-content\/uploads\/2024\/03\/1710865999698_0.jpg\" alt=\"\u5728\u7ebf\u7834\u89e3cap\u63e1\u624b\u5305\"><\/p>\n<pre><code class=\"language-text\">import zipfile \ntry:\n    with zipfile.ZipFile('test.zip') as zFile:     \n        # \u521b\u5efaZipFile\u5bf9\u8c61\n        # \u89e3\u538b\u6587\u4ef6\n        zFile.extractall(path='.\/',pwd=b'1234')\n        print('\u89e3\u538b\u6210\u529f!')\nexcept:\n    print('\u89e3\u538b\u5931\u8d25')<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/www.ccwifi.cc\/blogs\/wp-content\/uploads\/2024\/03\/1710865999698_1.jpg\" alt=\"\u5728\u7ebf\u7834\u89e3cap\u63e1\u624b\u5305\"><\/p>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5c06\u5206\u4eab\u4e00\u4e2a\u5173\u4e8e\u5728\u7ebfwifi\u8dd1\u5305\u3001\u91d1\u521a\u5305\u8dd1\u5305\u3001cap\u8dd1\u5305\u3001hccapx\u3001ewsa\u5728\u7ebf\u548c\u63e1\u624b\u5305\u8dd1\u5305\u7684\u6559\u7a0b\u3002\u5e0c\u671b\u5927\u5bb6\u80fd\u591f\u4ed4\u7ec6\u5b66\u4e60\u548c\u7406\u89e3\u3002\u5728\u4e4b\u524d\u7684\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u4f7f\u7528Python\u811a\u672c\u6765\u7834\u89e3ZIP\u538b\u7f29\u5305\u7684\u65b9\u6cd5\u3002\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u5f00\u59cb\u6574\u4e2a\u8fc7\u7a0b\u7684\u5c55\u793a\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u5bc6\u7801\u5b57\u5178\uff0c\u5176\u4e2d\u5305\u542b\u5e38\u89c1\u7684\u5bc6\u7801\u7ec4\u5408\u3002\u4f8b\u5982\uff0c\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u7531\u7eaf\u6570\u5b57\u7ec4\u6210\u7684\u516d\u4f4d\u5bc6\u7801&#8221;050825&#8243;\uff0c\u6211\u4eec\u53ef\u4ee5\u904d\u5386\u4ece&#8221;000000&#8243;\u5230&#8221;999999&#8243;\u7684\u6240\u6709\u53ef\u80fd\u5bc6\u7801\uff0c\u5e76\u5c06\u7ed3\u679c\u4fdd\u5b58\u5230\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\u4e2d\u3002<\/p>\n<p>\u7136\u800c\uff0c\u8fd9\u79cd\u65b9\u6cd5\u7684\u7f3a\u70b9\u662f\u6bd4\u8f83\u6b7b\u677f\uff0c\u53ea\u80fd\u5904\u7406\u516d\u4f4d\u6570\u5b57\u5bc6\u7801\uff0c\u5e76\u4e14\u53ef\u80fd\u5360\u7528\u5927\u91cf\u5185\u5b58\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6709\u4eba\u5f00\u53d1\u4e86\u4e00\u4e2a&#8221;\u5b57\u5178\u751f\u6210\u5668&#8221;\uff0c\u5b83\u53ef\u4ee5\u6839\u636e\u4f20\u5165\u7684\u53c2\u6570\u751f\u6210\u5bc6\u7801\u7684Python\u751f\u6210\u5668\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u7eaf\u6570\u5b57\u5bc6\u7801&#8221;050825&#8243;\uff0c\u6211\u4eec\u53ef\u4ee5\u4f20\u5165\u4ee5\u4e0b\u53c2\u6570\uff1a<\/p>\n<p>\u8fd9\u6837\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u751f\u6210\u5bc6\u7801\u3002\u800c\u4e14\uff0c\u7531\u4e8e\u751f\u6210\u5668\u4e0d\u4f1a\u5360\u7528\u592a\u591a\u5185\u5b58\uff0c\u6211\u4eec\u53ef\u4ee5\u5904\u7406\u66f4\u957f\u7684\u5bc6\u7801\u6216\u8005\u5305\u542b\u5176\u4ed6\u5b57\u7b26\u7684\u5bc6\u7801\u3002<\/p>\n<p>\u5f53\u6211\u4eec\u9700\u8981\u89e3\u538bZIP\u6587\u4ef6\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u81ea\u5e26\u7684zipfile\u6a21\u5757\u3002\u8be5\u6a21\u5757\u63d0\u4f9b\u4e86\u8bfb\u53d6\u3001\u5199\u5165\u3001\u8ffd\u52a0\u548c\u89e3\u538bZIP\u6587\u4ef6\u7684\u529f\u80fd\u3002\u5176\u4e2d\uff0c\u89e3\u538b\u64cd\u4f5c\u4e3b\u8981\u4f7f\u7528ZipFile\u5bf9\u8c61\u7684extractall()\u65b9\u6cd5\u3002\u8be5\u65b9\u6cd5\u6709\u4e09\u4e2a\u4e3b\u8981\u53c2\u6570\uff0c\u8ba9\u6211\u4eec\u6765\u770b\u770b\u6bcf\u4e2a\u53c2\u6570\u7684\u542b\u4e49\uff1a<\/p>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u8fd8\u5c06\u4f7f\u7528\u4e0a\u6b21\u4ecb\u7ecd\u7684\u8fdb\u5ea6\u6761\u53ef\u89c6\u5316\u6280\u672f\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u6211\u4eec\u4f7f\u7528\u4e86tqdm\u6269\u5c55\u5e93\u6765\u521b\u5efa\u8fdb\u5ea6\u6761\u3002\u5982\u679c\u4f60\u5bf9\u8fdb\u5ea6\u6761\u4e0d\u719f\u6089\uff0c\u53ef\u4ee5\u53c2\u8003\u4e0b\u9762\u7684\u94fe\u63a5\u4e86\u89e3\u66f4\u591a\uff1a\u7528Python\u5236\u4f5c\u53ef\u89c6\u5316\u8fdb\u5ea6\u6761\u3002<\/p>\n<p>\u5728\u4ee3\u7801\u4e2d\uff0ctqdm\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n<p>\u6700\u540e\uff0c\u611f\u8c22\u60a8\u9605\u8bfb\u672c\u6587\u3002\u8fd9\u662fPython\u5b9e\u7528\u811a\u672c\u7cfb\u5217\u7684\u6700\u540e\u4e00\u7bc7\u6587\u7ae0\u3002\u4e0b\u4e00\u7bc7\u6587\u7ae0\u5c06\u5206\u4eab\u5982\u4f55\u6279\u91cf\u4e0b\u8f7d\u767e\u5ea6\u56fe\u7247\uff0c\u4e3b\u8981\u5185\u5bb9\u5305\u62ec\uff1a<\/p>\n<p><!-- \u6587\u7ae0\u6765\u6e90:https:\/\/www.ccwifi.cc\/blogs\/index.php\/2024\/03\/16\/Python%E5%AE%9E%E7%94%A8%E6%A1%88%E4%BE%8BPython%E8%84%9A%E6%9C%ACPython%E5%AE%9E%E7%8E%B0%E7%A0%B4%E8%AF%91zip%E5%8E%8B%E7%BC%A9%E5%8C%85\/ --><\/p>\n<p>\u5e0c\u671b\u8fd9\u4e9b\u5185\u5bb9\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\u3002\u8c22\u8c22\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python\u5b9e\u7528\u6848\u4f8b\uff0cPython\u811a\u672c\uff0cPython\u5b9e\u73b0\u7834\u8bd1zip\u538b\u7f29\u5305\u5728\u7ebfwifi\u8dd1\u5305 \u91d1\u521a\u5305\u8dd1\u5305 cap\u8dd1\u5305 hccapx ewsa\u5728\u7ebf \u5c31\u6765 \u63e1\u624b\u5305\u8dd1\u5305\u5404\u4f4d\u597d \u53c8\u89c1\u9762\u4e86 \u6211\u662f\u66f9\u64cd \u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u7bc7\u65b0\u7684\u6559\u7a0b\u5e0c\u671b\u5404\u4f4d\u7ec6\u5fc3\u5b66\u4e60 \u4f4e\u8c03\u7528\u7f51\u5728\u8fc7\u53bb\u7684\u6587\u7ae0\u4e2d<\/p>\n","protected":false},"author":1,"featured_media":2576,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-2575","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-1"],"_links":{"self":[{"href":"https:\/\/www.ccwifi.cc\/blogs\/wp-json\/wp\/v2\/posts\/2575","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ccwifi.cc\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ccwifi.cc\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ccwifi.cc\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ccwifi.cc\/blogs\/wp-json\/wp\/v2\/comments?post=2575"}],"version-history":[{"count":0,"href":"https:\/\/www.ccwifi.cc\/blogs\/wp-json\/wp\/v2\/posts\/2575\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ccwifi.cc\/blogs\/wp-json\/wp\/v2\/media\/2576"}],"wp:attachment":[{"href":"https:\/\/www.ccwifi.cc\/blogs\/wp-json\/wp\/v2\/media?parent=2575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccwifi.cc\/blogs\/wp-json\/wp\/v2\/categories?post=2575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccwifi.cc\/blogs\/wp-json\/wp\/v2\/tags?post=2575"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.ccwifi.cc\/blogs\/wp-json\/wp\/v2\/topic?post=2575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}