{"id":76262,"date":"2026-02-22T02:05:29","date_gmt":"2026-02-21T18:05:29","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/76262.html"},"modified":"2026-02-22T02:05:29","modified_gmt":"2026-02-21T18:05:29","slug":"python%e7%bc%96%e5%86%99%e7%b3%bb%e7%bb%9f%e5%9e%83%e5%9c%be%e6%b8%85%e7%90%86%e5%b7%a5%e5%85%b7","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/76262.html","title":{"rendered":"Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177"},"content":{"rendered":"<h4>Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177<\/h4>\n<p>\u4f7f\u7528Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u81ea\u52a8\u5316\u6e05\u7406\u4e34\u65f6\u6587\u4ef6\u3001\u7f13\u5b58\u6587\u4ef6\u7b49\u65e0\u7528\u6570\u636e&#xff0c;\u63d0\u5347\u7cfb\u7edf\u6027\u80fd\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\u7684\u5173\u952e\u6b65\u9aa4\u548c\u65b9\u6cd5\u3002<\/p>\n<h4>\u786e\u5b9a\u6e05\u7406\u76ee\u6807<\/h4>\n<p>\u660e\u786e\u9700\u8981\u6e05\u7406\u7684\u6587\u4ef6\u7c7b\u578b\u548c\u76ee\u5f55\u3002\u5e38\u89c1\u7684\u6e05\u7406\u76ee\u6807\u5305\u62ec\u4e34\u65f6\u6587\u4ef6&#xff08;.tmp&#xff09;\u3001\u65e5\u5fd7\u6587\u4ef6&#xff08;.log&#xff09;\u3001\u7f13\u5b58\u6587\u4ef6\u4ee5\u53ca\u56de\u6536\u7ad9\u4e2d\u7684\u6587\u4ef6\u3002Windows\u7cfb\u7edf\u4e2d&#xff0c;\u4e34\u65f6\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8eC:\\\\Windows\\\\Temp\u6216\u7528\u6237\u76ee\u5f55\u4e0b\u7684AppData\\\\Local\\\\Temp&#xff1b;Linux\u548cmacOS\u4e2d&#xff0c;\u4e34\u65f6\u6587\u4ef6\u591a\u4f4d\u4e8e\/tmp\u6216~\/.cache\u3002<\/p>\n<h4>\u5bfc\u5165\u5fc5\u8981\u7684\u5e93<\/h4>\n<p>\u4f7f\u7528Python\u5185\u7f6e\u7684os\u548cshutil\u5e93\u5904\u7406\u6587\u4ef6\u548c\u76ee\u5f55\u64cd\u4f5c\u3002os\u5e93\u7528\u4e8e\u8def\u5f84\u64cd\u4f5c\u548c\u6587\u4ef6\u68c0\u67e5&#xff0c;shutil\u5e93\u7528\u4e8e\u5220\u9664\u6587\u4ef6\u548c\u76ee\u5f55\u3002\u5982\u679c\u9700\u8981\u9012\u5f52\u5220\u9664\u76ee\u5f55&#xff0c;\u53ef\u4ee5\u7ed3\u5408\u4e24\u8005\u4f7f\u7528\u3002<\/p>\n<p><span class=\"token keyword\">import<\/span> os<br \/>\n<span class=\"token keyword\">import<\/span> shutil<\/p>\n<h4>\u5b9e\u73b0\u6587\u4ef6\u6e05\u7406\u903b\u8f91<\/h4>\n<p>\u5b9a\u4e49\u6e05\u7406\u51fd\u6570&#xff0c;\u904d\u5386\u76ee\u6807\u76ee\u5f55\u5e76\u5220\u9664\u5339\u914d\u7684\u6587\u4ef6\u3002\u53ef\u4ee5\u901a\u8fc7\u6587\u4ef6\u6269\u5c55\u540d\u6216\u6587\u4ef6\u540d\u6a21\u5f0f\u8bc6\u522b\u5783\u573e\u6587\u4ef6\u3002\u4f7f\u7528os.walk\u9012\u5f52\u904d\u5386\u76ee\u5f55&#xff0c;\u786e\u4fdd\u6240\u6709\u5b50\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u90fd\u88ab\u68c0\u67e5\u3002<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">clean_files<\/span><span class=\"token punctuation\">(<\/span>directory<span class=\"token punctuation\">,<\/span> extensions<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">for<\/span> root<span class=\"token punctuation\">,<\/span> _<span class=\"token punctuation\">,<\/span> files <span class=\"token keyword\">in<\/span> os<span class=\"token punctuation\">.<\/span>walk<span class=\"token punctuation\">(<\/span>directory<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">for<\/span> <span class=\"token builtin\">file<\/span> <span class=\"token keyword\">in<\/span> files<span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">if<\/span> <span class=\"token builtin\">any<\/span><span class=\"token punctuation\">(<\/span><span class=\"token builtin\">file<\/span><span class=\"token punctuation\">.<\/span>endswith<span class=\"token punctuation\">(<\/span>ext<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">for<\/span> ext <span class=\"token keyword\">in<\/span> extensions<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n                file_path <span class=\"token operator\">&#061;<\/span> os<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">.<\/span>join<span class=\"token punctuation\">(<\/span>root<span class=\"token punctuation\">,<\/span> <span class=\"token builtin\">file<\/span><span class=\"token punctuation\">)<\/span><br \/>\n                <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n                    os<span class=\"token punctuation\">.<\/span>remove<span class=\"token punctuation\">(<\/span>file_path<span class=\"token punctuation\">)<\/span><br \/>\n                    <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;Deleted: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>file_path<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n                <span class=\"token keyword\">except<\/span> Exception <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n                    <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;Error deleting <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>file_path<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>e<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><\/p>\n<h4>\u5904\u7406\u76ee\u5f55\u6e05\u7406<\/h4>\n<p>\u67d0\u4e9b\u60c5\u51b5\u4e0b\u9700\u8981\u5220\u9664\u6574\u4e2a\u76ee\u5f55&#xff0c;\u4f8b\u5982\u7f13\u5b58\u6587\u4ef6\u5939\u3002\u4f7f\u7528shutil.rmtree\u53ef\u4ee5\u9012\u5f52\u5220\u9664\u76ee\u5f55\u53ca\u5176\u5185\u5bb9\u3002\u6ce8\u610f\u786e\u4fdd\u76ee\u5f55\u786e\u5b9e\u9700\u8981\u6e05\u7406&#xff0c;\u907f\u514d\u8bef\u5220\u91cd\u8981\u6570\u636e\u3002<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">clean_directory<\/span><span class=\"token punctuation\">(<\/span>directory<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> os<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">.<\/span>exists<span class=\"token punctuation\">(<\/span>directory<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            shutil<span class=\"token punctuation\">.<\/span>rmtree<span class=\"token punctuation\">(<\/span>directory<span class=\"token punctuation\">)<\/span><br \/>\n            <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;Deleted directory: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>directory<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">except<\/span> Exception <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;Error deleting directory <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>directory<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>e<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">else<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;Directory not found: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>directory<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><\/p>\n<h4>\u6dfb\u52a0\u7528\u6237\u4ea4\u4e92<\/h4>\n<p>\u63d0\u4f9b\u547d\u4ee4\u884c\u754c\u9762\u8ba9\u7528\u6237\u9009\u62e9\u6e05\u7406\u9009\u9879\u3002\u4f7f\u7528argparse\u5e93\u89e3\u6790\u547d\u4ee4\u884c\u53c2\u6570&#xff0c;\u5141\u8bb8\u7528\u6237\u6307\u5b9a\u6e05\u7406\u76ee\u6807\u6216\u542f\u7528\u7279\u5b9a\u529f\u80fd\u3002<\/p>\n<p><span class=\"token keyword\">import<\/span> argparse<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    parser <span class=\"token operator\">&#061;<\/span> argparse<span class=\"token punctuation\">.<\/span>ArgumentParser<span class=\"token punctuation\">(<\/span>description<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;System Cleanup Tool&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    parser<span class=\"token punctuation\">.<\/span>add_argument<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;&#8211;temp&#034;<\/span><span class=\"token punctuation\">,<\/span> action<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;store_true&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token builtin\">help<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;Clean temporary files&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    parser<span class=\"token punctuation\">.<\/span>add_argument<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;&#8211;cache&#034;<\/span><span class=\"token punctuation\">,<\/span> action<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;store_true&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token builtin\">help<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;Clean cache files&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    args <span class=\"token operator\">&#061;<\/span> parser<span class=\"token punctuation\">.<\/span>parse_args<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token keyword\">if<\/span> args<span class=\"token punctuation\">.<\/span>temp<span class=\"token punctuation\">:<\/span><br \/>\n        temp_dir <span class=\"token operator\">&#061;<\/span> os<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">.<\/span>join<span class=\"token punctuation\">(<\/span>os<span class=\"token punctuation\">.<\/span>environ<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;TEMP&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\/tmp&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        clean_files<span class=\"token punctuation\">(<\/span>temp_dir<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;.tmp&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;.log&#034;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> args<span class=\"token punctuation\">.<\/span>cache<span class=\"token punctuation\">:<\/span><br \/>\n        cache_dir <span class=\"token operator\">&#061;<\/span> os<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">.<\/span>expanduser<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;~\/.cache&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        clean_directory<span class=\"token punctuation\">(<\/span>cache_dir<span class=\"token punctuation\">)<\/span><\/p>\n<h4>\u5b89\u5168\u6027\u548c\u9519\u8bef\u5904\u7406<\/h4>\n<p>\u786e\u4fdd\u6e05\u7406\u64cd\u4f5c\u4e0d\u4f1a\u8bef\u5220\u91cd\u8981\u6587\u4ef6\u3002\u5728\u5220\u9664\u524d\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u53ef\u5220\u9664&#xff0c;\u6355\u83b7\u5e76\u5904\u7406\u53ef\u80fd\u7684\u5f02\u5e38&#xff0c;\u5982\u6743\u9650\u4e0d\u8db3\u6216\u6587\u4ef6\u6b63\u5728\u4f7f\u7528\u3002\u8bb0\u5f55\u6e05\u7406\u64cd\u4f5c\u7684\u7ed3\u679c&#xff0c;\u65b9\u4fbf\u7528\u6237\u67e5\u770b\u54ea\u4e9b\u6587\u4ef6\u88ab\u5220\u9664\u3002<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">safe_delete<\/span><span class=\"token punctuation\">(<\/span>file_path<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> os<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">.<\/span>isfile<span class=\"token punctuation\">(<\/span>file_path<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            os<span class=\"token punctuation\">.<\/span>remove<span class=\"token punctuation\">(<\/span>file_path<span class=\"token punctuation\">)<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">True<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">False<\/span><br \/>\n    <span class=\"token keyword\">except<\/span> Exception <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;Failed to delete <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>file_path<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>e<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">False<\/span><\/p>\n<h4>\u6269\u5c55\u529f\u80fd<\/h4>\n<p>\u53ef\u4ee5\u6dfb\u52a0\u66f4\u591a\u529f\u80fd&#xff0c;\u5982\u6e05\u7406\u6d4f\u89c8\u5668\u7f13\u5b58\u3001\u6e05\u7a7a\u56de\u6536\u7ad9\u6216\u751f\u6210\u6e05\u7406\u62a5\u544a\u3002\u8c03\u7528\u7cfb\u7edf\u547d\u4ee4\u6216\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93&#xff08;\u5982send2trash&#xff09;\u5b9e\u73b0\u66f4\u590d\u6742\u7684\u6e05\u7406\u4efb\u52a1\u3002<\/p>\n<p><span class=\"token keyword\">import<\/span> send2trash<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">empty_recycle_bin<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        send2trash<span class=\"token punctuation\">.<\/span>send2trash<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># Empty the recycle bin<\/span><br \/>\n        <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Recycle bin emptied&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">except<\/span> Exception <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;Error emptying recycle bin: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>e<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><\/p>\n<h4>\u6253\u5305\u4e3a\u53ef\u6267\u884c\u6587\u4ef6<\/h4>\n<p>\u4f7f\u7528PyInstaller\u6216cx_Freeze\u5c06\u811a\u672c\u6253\u5305\u4e3a\u53ef\u6267\u884c\u6587\u4ef6&#xff0c;\u65b9\u4fbf\u7528\u6237\u76f4\u63a5\u8fd0\u884c\u3002\u5b89\u88c5\u5de5\u5177\u540e&#xff0c;\u8fd0\u884c\u7b80\u5355\u7684\u547d\u4ee4\u5373\u53ef\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<p>pyinstaller &#8211;onefile cleanup_tool.py<\/p>\n<h4>\u6ce8\u610f\u4e8b\u9879<\/h4>\n<ul>\n<li>\u8c28\u614e\u9009\u62e9\u6e05\u7406\u76ee\u6807&#xff0c;\u907f\u514d\u5220\u9664\u7cfb\u7edf\u5173\u952e\u6587\u4ef6\u3002<\/li>\n<li>\u5728\u5220\u9664\u524d\u786e\u8ba4\u6587\u4ef6\u8def\u5f84\u548c\u6269\u5c55\u540d&#xff0c;\u9632\u6b62\u8bef\u5220\u3002<\/li>\n<li>\u63d0\u4f9b\u64a4\u9500\u6216\u5907\u4efd\u529f\u80fd&#xff0c;\u4ee5\u9632\u7528\u6237\u9700\u8981\u6062\u590d\u8bef\u5220\u7684\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4&#xff0c;\u53ef\u4ee5\u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u4f46\u529f\u80fd\u5b8c\u5584\u7684\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177&#xff0c;\u5e2e\u52a9\u7528\u6237\u9ad8\u6548\u7ba1\u7406\u78c1\u76d8\u7a7a\u95f4\u3002<\/p>\n<p>\u65e0\u5173\u6280\u672f\u9ad8\u4f4e&#xff0c;\u53ea\u662f\u4e00\u4efd\u7b80\u5355\u7684\u4e50\u8da3\u4e0e\u56de\u5fc6\u3002\u4ee5\u540e\u6709\u7a7a&#xff0c;\u6216\u8bb8\u8fd8\u80fd\u518d\u4f18\u5316\u4f18\u5316&#xff0c;\u63d0\u5347\u4e00\u4e0b\u7f16\u7a0b\u7684\u6c34\u5e73&#xff0c;\u6216\u662f\u52a0\u4e00\u70b9\u66f4\u8d34\u5fc3\u7684\u5c0f\u529f\u80fd&#xff0c;\u6bd5\u7adf&#xff0c;\u70ed\u7231\u4ece\u6765\u90fd\u4e0d\u5206\u8f7b\u91cd&#xff0c;\u968f\u624b\u800c\u4e3a\u7684\u7f8e\u597d&#xff0c;\u4e5f\u503c\u5f97\u88ab\u8bb0\u5f55\u3002\u6536\u85cf\u70b9\u8d5e\u5173\u6ce8\u8f6c\u53d1\u90fd\u6709\u79ef\u5206\u54e6\u3002<\/p>\n<p>\u70b9\u4e2a\u5173\u6ce8<br \/>\n\u8fdb\u5165\u6211\u4e3b\u9875\u300c\u8d44\u6e90\u300d<br \/>\n\u514d\u8d39\u4e0b\u8f7d&#xff0c;\u76f4\u63a5\u8fd0\u884c<br \/>\n\u6301\u7eed\u5206\u4eabPython\/\u7f51\u9875\/\u5c0f\u7a0b\u5e8f\/\u7535\u8111\u5b9e\u7528\u5de5\u5177&#xff0c;<br \/>\n\u4e0d\u5957\u8def\u3001\u4e0d\u52a0\u5bc6&#xff0c;\u5173\u6ce8\u4e0d\u8ff7\u8def&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177<br \/>\n\u4f7f\u7528Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u81ea\u52a8\u5316\u6e05\u7406\u4e34\u65f6\u6587\u4ef6\u3001\u7f13\u5b58\u6587\u4ef6\u7b49\u65e0\u7528\u6570\u636e&#xff0c;\u63d0\u5347\u7cfb\u7edf\u6027\u80fd\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\u7684\u5173\u952e\u6b65\u9aa4\u548c\u65b9\u6cd5\u3002<br \/>\n\u786e\u5b9a\u6e05\u7406\u76ee\u6807<br \/>\n\u660e\u786e\u9700\u8981\u6e05\u7406\u7684\u6587\u4ef6\u7c7b\u578b\u548c\u76ee\u5f55\u3002\u5e38\u89c1\u7684\u6e05\u7406\u76ee\u6807\u5305\u62ec\u4e34\u65f6\u6587\u4ef6&#xff08;.tmp&#xff09;\u3001\u65e5\u5fd7\u6587\u4ef6&#xff08;.log&#xff09;\u3001\u7f13\u5b58\u6587\u4ef6\u4ee5\u53ca\u56de\u6536\u7ad9\u4e2d\u7684\u6587\u4ef6\u3002Windows\u7cfb\u7edf\u4e2d&#xff0c;\u4e34\u65f6\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8eC:\\\\Windows\\\\Temp\u6216\u7528\u6237\u76ee\u5f55\u4e0b\u7684App<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,230,81,101,149,190,124],"topic":[],"class_list":["post-76262","post","type-post","status-publish","format-standard","hentry","category-server","tag-java","tag-php","tag-python","tag-spring","tag-windows","tag-190","tag-124"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/76262.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177 \u4f7f\u7528Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u81ea\u52a8\u5316\u6e05\u7406\u4e34\u65f6\u6587\u4ef6\u3001\u7f13\u5b58\u6587\u4ef6\u7b49\u65e0\u7528\u6570\u636e&#xff0c;\u63d0\u5347\u7cfb\u7edf\u6027\u80fd\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\u7684\u5173\u952e\u6b65\u9aa4\u548c\u65b9\u6cd5\u3002 \u786e\u5b9a\u6e05\u7406\u76ee\u6807 \u660e\u786e\u9700\u8981\u6e05\u7406\u7684\u6587\u4ef6\u7c7b\u578b\u548c\u76ee\u5f55\u3002\u5e38\u89c1\u7684\u6e05\u7406\u76ee\u6807\u5305\u62ec\u4e34\u65f6\u6587\u4ef6&#xff08;.tmp&#xff09;\u3001\u65e5\u5fd7\u6587\u4ef6&#xff08;.log&#xff09;\u3001\u7f13\u5b58\u6587\u4ef6\u4ee5\u53ca\u56de\u6536\u7ad9\u4e2d\u7684\u6587\u4ef6\u3002Windows\u7cfb\u7edf\u4e2d&#xff0c;\u4e34\u65f6\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8eC:\\Windows\\Temp\u6216\u7528\u6237\u76ee\u5f55\u4e0b\u7684App\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/76262.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-21T18:05:29+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76262.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/76262.html\",\"name\":\"Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-21T18:05:29+00:00\",\"dateModified\":\"2026-02-21T18:05:29+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/76262.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/76262.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76262.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/76262.html","og_locale":"zh_CN","og_type":"article","og_title":"Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177 \u4f7f\u7528Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u81ea\u52a8\u5316\u6e05\u7406\u4e34\u65f6\u6587\u4ef6\u3001\u7f13\u5b58\u6587\u4ef6\u7b49\u65e0\u7528\u6570\u636e&#xff0c;\u63d0\u5347\u7cfb\u7edf\u6027\u80fd\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\u7684\u5173\u952e\u6b65\u9aa4\u548c\u65b9\u6cd5\u3002 \u786e\u5b9a\u6e05\u7406\u76ee\u6807 \u660e\u786e\u9700\u8981\u6e05\u7406\u7684\u6587\u4ef6\u7c7b\u578b\u548c\u76ee\u5f55\u3002\u5e38\u89c1\u7684\u6e05\u7406\u76ee\u6807\u5305\u62ec\u4e34\u65f6\u6587\u4ef6&#xff08;.tmp&#xff09;\u3001\u65e5\u5fd7\u6587\u4ef6&#xff08;.log&#xff09;\u3001\u7f13\u5b58\u6587\u4ef6\u4ee5\u53ca\u56de\u6536\u7ad9\u4e2d\u7684\u6587\u4ef6\u3002Windows\u7cfb\u7edf\u4e2d&#xff0c;\u4e34\u65f6\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8eC:\\Windows\\Temp\u6216\u7528\u6237\u76ee\u5f55\u4e0b\u7684App","og_url":"https:\/\/www.wsisp.com\/helps\/76262.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-21T18:05:29+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/76262.html","url":"https:\/\/www.wsisp.com\/helps\/76262.html","name":"Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-21T18:05:29+00:00","dateModified":"2026-02-21T18:05:29+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/76262.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/76262.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/76262.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Python\u7f16\u5199\u7cfb\u7edf\u5783\u573e\u6e05\u7406\u5de5\u5177"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76262","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=76262"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76262\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=76262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=76262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=76262"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=76262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}