{"id":976914,"date":"2024-12-27T06:25:21","date_gmt":"2024-12-26T22:25:21","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/976914.html"},"modified":"2024-12-27T06:25:24","modified_gmt":"2024-12-26T22:25:24","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e5%88%a0%e9%99%a4%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/976914.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u5220\u9664\u6587\u4ef6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24202415\/4e6dc27e-862f-4620-9d9e-e12a8de6c6b6.webp\" alt=\"python\u4e2d\u5982\u4f55\u5220\u9664\u6587\u4ef6\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u5220\u9664\u6587\u4ef6\u53ef\u4ee5\u4f7f\u7528os\u6a21\u5757\u4e2d\u7684remove()\u51fd\u6570\u3001\u901a\u8fc7\u5f02\u5e38\u5904\u7406\u6765\u786e\u4fdd\u6587\u4ef6\u5220\u9664\u7684\u5b89\u5168\u6027\u3001\u4f7f\u7528pathlib\u5e93\u63d0\u4f9b\u66f4\u73b0\u4ee3\u7684\u6587\u4ef6\u64cd\u4f5c\u63a5\u53e3<\/strong>\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e09\u79cd\u65b9\u6cd5\u4e2d\u7684\u4e00\u79cd\uff1aos\u6a21\u5757\u4e2d\u7684remove()\u51fd\u6570\u3002os\u6a21\u5757\u662fPython\u6807\u51c6\u5e93\u7684\u4e00\u90e8\u5206\uff0c\u4e13\u95e8\u7528\u4e8e\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u4ea4\u4e92\uff0c\u56e0\u6b64\u4f7f\u7528\u5b83\u5220\u9664\u6587\u4ef6\u662f\u4e00\u4e2a\u5e38\u89c1\u4e14\u53ef\u9760\u7684\u9009\u62e9\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f7f\u7528os\u6a21\u5757\u4e2d\u7684remove()\u51fd\u6570\u6765\u5220\u9664\u6587\u4ef6\u3002os.remove()\u51fd\u6570\u662fPython\u63d0\u4f9b\u7684\u4e00\u4e2a\u7b80\u5355\u800c\u76f4\u63a5\u7684\u6587\u4ef6\u5220\u9664\u65b9\u6cd5\u3002\u901a\u8fc7\u8c03\u7528os.remove()\u5e76\u4f20\u5165\u8981\u5220\u9664\u7684\u6587\u4ef6\u8def\u5f84\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u5220\u9664\u6587\u4ef6\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u6307\u5b9a\u7684\u6587\u4ef6\u4e0d\u5b58\u5728\uff0cos.remove()\u5c06\u5f15\u53d1\u4e00\u4e2aFileNotFoundError\u5f02\u5e38\u3002\u56e0\u6b64\uff0c\u7ed3\u5408try-except\u8bed\u53e5\u8fdb\u884c\u5f02\u5e38\u5904\u7406\u53ef\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u5065\u58ee\u6027\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>try:<\/p>\n<p>    os.remove(&quot;example.txt&quot;)<\/p>\n<p>    print(&quot;File deleted successfully&quot;)<\/p>\n<p>except FileNotFoundError:<\/p>\n<p>    print(&quot;File not found&quot;)<\/p>\n<p>except Exception as e:<\/p>\n<p>    print(f&quot;An error occurred: {e}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e00\u3001OS\u6a21\u5757\u4e2d\u7684REMOVE()\u51fd\u6570<\/p>\n<\/p>\n<p><p>os\u6a21\u5757\u662fPython\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u4ea4\u4e92\u7684\u6807\u51c6\u5e93\u4e4b\u4e00\uff0c\u63d0\u4f9b\u4e86\u8bb8\u591a\u7528\u4e8e\u5904\u7406\u6587\u4ef6\u548c\u76ee\u5f55\u7684\u65b9\u6cd5\u3002os.remove()\u51fd\u6570\u662f\u5176\u4e2d\u7528\u4e8e\u5220\u9664\u6587\u4ef6\u7684\u4e3b\u8981\u65b9\u6cd5\u3002\u4e86\u89e3\u5982\u4f55\u4f7f\u7528os\u6a21\u5757\u5220\u9664\u6587\u4ef6\u662fPython\u7a0b\u5e8f\u5458\u7684\u57fa\u672c\u6280\u80fd\u4e4b\u4e00\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528os.remove()\u51fd\u6570<\/strong><\/p>\n<\/p>\n<p><p>os.remove()\u662f\u4e00\u4e2a\u7b80\u5355\u800c\u76f4\u63a5\u7684\u6587\u4ef6\u5220\u9664\u65b9\u6cd5\u3002\u53ea\u9700\u63d0\u4f9b\u6587\u4ef6\u8def\u5f84\u4f5c\u4e3a\u53c2\u6570\uff0c\u5b83\u5c06\u5c1d\u8bd5\u5220\u9664\u8be5\u6587\u4ef6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<h2><strong>\u6307\u5b9a\u8981\u5220\u9664\u7684\u6587\u4ef6<\/strong><\/h2>\n<p>file_path = &quot;example.txt&quot;<\/p>\n<h2><strong>\u5220\u9664\u6587\u4ef6<\/strong><\/h2>\n<p>os.remove(file_path)<\/p>\n<p>print(f&quot;{file_path} has been deleted.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5bfc\u5165\u4e86os\u6a21\u5757\u5e76\u8c03\u7528os.remove()\u51fd\u6570\uff0c\u4f20\u5165\u6587\u4ef6\u8def\u5f84&quot;example.txt&quot;\uff0c\u7a0b\u5e8f\u5c06\u5220\u9664\u8be5\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5f02\u5e38\u5904\u7406<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528os.remove()\u5220\u9664\u6587\u4ef6\u65f6\uff0c\u6709\u53ef\u80fd\u4f1a\u9047\u5230\u6587\u4ef6\u4e0d\u5b58\u5728\u6216\u5176\u4ed6\u9519\u8bef\u60c5\u51b5\u3002\u56e0\u6b64\uff0c\u4f7f\u7528try-except\u8bed\u53e5\u5904\u7406\u5f02\u5e38\u662f\u4e2a\u597d\u4e60\u60ef\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>file_path = &quot;example.txt&quot;<\/p>\n<p>try:<\/p>\n<p>    os.remove(file_path)<\/p>\n<p>    print(f&quot;{file_path} has been deleted.&quot;)<\/p>\n<p>except FileNotFoundError:<\/p>\n<p>    print(f&quot;The file {file_path} does not exist.&quot;)<\/p>\n<p>except PermissionError:<\/p>\n<p>    print(f&quot;Permission denied: Unable to delete {file_path}.&quot;)<\/p>\n<p>except Exception as e:<\/p>\n<p>    print(f&quot;An error occurred: {e}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5904\u7406\u4e86\u4e09\u79cd\u5e38\u89c1\u7684\u5f02\u5e38\uff1aFileNotFoundError\u8868\u793a\u6587\u4ef6\u4e0d\u5b58\u5728\uff0cPermissionError\u8868\u793a\u6743\u9650\u4e0d\u8db3\uff0c\u6700\u540e\u4e00\u4e2a\u901a\u7528\u5f02\u5e38\u5904\u7406\u53ef\u4ee5\u6355\u83b7\u5176\u4ed6\u53ef\u80fd\u7684\u9519\u8bef\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u901a\u8fc7\u5f02\u5e38\u5904\u7406\u6765\u786e\u4fdd\u6587\u4ef6\u5220\u9664\u7684\u5b89\u5168\u6027<\/p>\n<\/p>\n<p><p>\u5728\u5220\u9664\u6587\u4ef6\u65f6\uff0c\u786e\u4fdd\u64cd\u4f5c\u5b89\u5168\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u901a\u8fc7\u5f02\u5e38\u5904\u7406\uff0c\u53ef\u4ee5\u6355\u83b7\u5e76\u5904\u7406\u5404\u79cd\u53ef\u80fd\u51fa\u73b0\u7684\u9519\u8bef\uff0c\u4ece\u800c\u63d0\u9ad8\u7a0b\u5e8f\u7684\u5065\u58ee\u6027\u548c\u53ef\u9760\u6027\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>FileNotFoundError\u5f02\u5e38<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u5c1d\u8bd5\u5220\u9664\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u6587\u4ef6\uff0cos.remove()\u4f1a\u5f15\u53d1FileNotFoundError\u5f02\u5e38\u3002\u56e0\u6b64\uff0c\u5728\u5220\u9664\u6587\u4ef6\u524d\uff0c\u53ef\u4ee5\u5148\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u5b58\u5728\uff0c\u6216\u8005\u5728\u5220\u9664\u65f6\u5904\u7406\u8be5\u5f02\u5e38\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>file_path = &quot;example.txt&quot;<\/p>\n<p>if os.path.exists(file_path):<\/p>\n<p>    os.remove(file_path)<\/p>\n<p>    print(f&quot;{file_path} has been deleted.&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(f&quot;The file {file_path} does not exist.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528os.path.exists()\u51fd\u6570\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u5b58\u5728\uff0c\u53ea\u6709\u5728\u6587\u4ef6\u5b58\u5728\u65f6\u624d\u5c1d\u8bd5\u5220\u9664\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6743\u9650\u95ee\u9898<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u6ca1\u6709\u6743\u9650\u5220\u9664\u67d0\u4e9b\u6587\u4ef6\u3002\u8fd9\u65f6os.remove()\u4f1a\u5f15\u53d1PermissionError\u5f02\u5e38\u3002\u5904\u7406\u6743\u9650\u95ee\u9898\u53ef\u4ee5\u5e2e\u52a9\u7a0b\u5e8f\u66f4\u4f18\u96c5\u5730\u5931\u8d25\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>file_path = &quot;example.txt&quot;<\/p>\n<p>try:<\/p>\n<p>    os.remove(file_path)<\/p>\n<p>    print(f&quot;{file_path} has been deleted.&quot;)<\/p>\n<p>except PermissionError:<\/p>\n<p>    print(f&quot;Permission denied: Unable to delete {file_path}.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u6355\u83b7PermissionError\u5f02\u5e38\uff0c\u60a8\u53ef\u4ee5\u5728\u6743\u9650\u4e0d\u8db3\u65f6\u5411\u7528\u6237\u63d0\u4f9b\u6709\u7528\u7684\u53cd\u9988\u4fe1\u606f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528PATHLIB\u5e93\u63d0\u4f9b\u66f4\u73b0\u4ee3\u7684\u6587\u4ef6\u64cd\u4f5c\u63a5\u53e3<\/p>\n<\/p>\n<p><p>pathlib\u5e93\u662fPython 3.4\u5f15\u5165\u7684\u4e00\u4e2a\u6a21\u5757\uff0c\u63d0\u4f9b\u4e86\u9762\u5411\u5bf9\u8c61\u7684\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\u64cd\u4f5c\u63a5\u53e3\u3002\u76f8\u6bd4\u4f20\u7edf\u7684os\u6a21\u5757\uff0cpathlib\u66f4\u52a0\u76f4\u89c2\u548c\u6613\u4e8e\u4f7f\u7528\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u57fa\u672c\u7528\u6cd5<\/strong><\/p>\n<\/p>\n<p><p>pathlib\u63d0\u4f9b\u4e86Path\u5bf9\u8c61\u7528\u4e8e\u8868\u793a\u6587\u4ef6\u8def\u5f84\u3002\u4f7f\u7528Path\u5bf9\u8c61\u7684unlink()\u65b9\u6cd5\u53ef\u4ee5\u5220\u9664\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pathlib import Path<\/p>\n<h2><strong>\u521b\u5efaPath\u5bf9\u8c61<\/strong><\/h2>\n<p>file_path = Path(&quot;example.txt&quot;)<\/p>\n<h2><strong>\u5220\u9664\u6587\u4ef6<\/strong><\/h2>\n<p>try:<\/p>\n<p>    file_path.unlink()<\/p>\n<p>    print(f&quot;{file_path} has been deleted.&quot;)<\/p>\n<p>except FileNotFoundError:<\/p>\n<p>    print(f&quot;The file {file_path} does not exist.&quot;)<\/p>\n<p>except PermissionError:<\/p>\n<p>    print(f&quot;Permission denied: Unable to delete {file_path}.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u521b\u5efa\u4e86\u4e00\u4e2aPath\u5bf9\u8c61\uff0c\u7136\u540e\u8c03\u7528unlink()\u65b9\u6cd5\u5220\u9664\u6587\u4ef6\u3002pathlib\u7684\u9762\u5411\u5bf9\u8c61\u8bbe\u8ba1\u4f7f\u5f97\u4ee3\u7801\u66f4\u52a0\u6e05\u6670\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u5b58\u5728<\/strong><\/p>\n<\/p>\n<p><p>\u4e0eos.path.exists()\u7c7b\u4f3c\uff0cPath\u5bf9\u8c61\u63d0\u4f9b\u4e86exists()\u65b9\u6cd5\u7528\u4e8e\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u5b58\u5728\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pathlib import Path<\/p>\n<p>file_path = Path(&quot;example.txt&quot;)<\/p>\n<p>if file_path.exists():<\/p>\n<p>    file_path.unlink()<\/p>\n<p>    print(f&quot;{file_path} has been deleted.&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(f&quot;The file {file_path} does not exist.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528Path\u5bf9\u8c61\u7684exists()\u65b9\u6cd5\u6765\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u5b58\u5728\u3002pathlib\u7684API\u8bbe\u8ba1\u4f7f\u5f97\u4ee3\u7801\u66f4\u52a0\u7b80\u6d01\u660e\u4e86\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u4e09\u79cd\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u5728Python\u4e2d\u5b89\u5168\u5730\u5220\u9664\u6587\u4ef6\u3002\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53d6\u51b3\u4e8e\u60a8\u7684\u9700\u6c42\u548c\u504f\u597d\u3002\u65e0\u8bba\u4f7f\u7528\u54ea\u79cd\u65b9\u6cd5\uff0c\u786e\u4fdd\u4ee3\u7801\u4e2d\u5305\u542b\u9002\u5f53\u7684\u5f02\u5e38\u5904\u7406\uff0c\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u5065\u58ee\u6027\u548c\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b89\u5168\u5730\u5220\u9664\u6587\u4ef6\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>os<\/code>\u6a21\u5757\u4e2d\u7684<code>remove()<\/code>\u51fd\u6570\u5b89\u5168\u5730\u5220\u9664\u6587\u4ef6\u3002\u5728\u4f7f\u7528\u8be5\u51fd\u6570\u4e4b\u524d\uff0c\u786e\u4fdd\u6587\u4ef6\u8def\u5f84\u6b63\u786e\u5e76\u4e14\u6587\u4ef6\u786e\u5b9e\u5b58\u5728\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">import os\n\nfile_path = &#39;path\/to\/your\/file.txt&#39;\nif os.path.exists(file_path):\n    os.remove(file_path)\n    print(f&quot;{file_path} \u5df2\u6210\u529f\u5220\u9664&quot;)\nelse:\n    print(f&quot;{file_path} \u4e0d\u5b58\u5728&quot;)\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u7b80\u5355\u660e\u4e86\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u5220\u9664\u6307\u5b9a\u7684\u6587\u4ef6\u3002<\/p>\n<p><strong>\u4f7f\u7528Python\u5220\u9664\u6587\u4ef6\u65f6\uff0c\u662f\u5426\u9700\u8981\u5904\u7406\u5f02\u5e38\uff1f<\/strong><br \/>\u5904\u7406\u5f02\u5e38\u5728\u6587\u4ef6\u64cd\u4f5c\u4e2d\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u5f53\u5c1d\u8bd5\u5220\u9664\u4e00\u4e2a\u6587\u4ef6\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u6743\u9650\u95ee\u9898\u6216\u6587\u4ef6\u6b63\u5728\u4f7f\u7528\u7684\u60c5\u51b5\u3002\u901a\u8fc7\u4f7f\u7528<code>try-except<\/code>\u7ed3\u6784\uff0c\u53ef\u4ee5\u6355\u83b7\u8fd9\u4e9b\u5f02\u5e38\u5e76\u8fdb\u884c\u76f8\u5e94\u5904\u7406\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">import os\n\nfile_path = &#39;path\/to\/your\/file.txt&#39;\ntry:\n    os.remove(file_path)\n    print(f&quot;{file_path} \u5df2\u6210\u529f\u5220\u9664&quot;)\nexcept FileNotFoundError:\n    print(f&quot;{file_path} \u4e0d\u5b58\u5728&quot;)\nexcept PermissionError:\n    print(f&quot;\u6ca1\u6709\u6743\u9650\u5220\u9664 {file_path}&quot;)\nexcept Exception as e:\n    print(f&quot;\u5220\u9664\u6587\u4ef6\u65f6\u53d1\u751f\u9519\u8bef: {e}&quot;)\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u505a\u6cd5\u80fd\u63d0\u9ad8\u4ee3\u7801\u7684\u5065\u58ee\u6027\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\uff0c\u5982\u4f55\u5220\u9664\u591a\u4e2a\u6587\u4ef6\uff1f<\/strong><br \/>\u5982\u679c\u9700\u8981\u5220\u9664\u591a\u4e2a\u6587\u4ef6\uff0c\u53ef\u4ee5\u904d\u5386\u6587\u4ef6\u5217\u8868\u5e76\u9010\u4e2a\u5220\u9664\u3002\u4f7f\u7528<code>os.remove()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a  <\/p>\n<pre><code class=\"language-python\">import os\n\nfiles_to_delete = [&#39;file1.txt&#39;, &#39;file2.txt&#39;, &#39;file3.txt&#39;]\nfor file_path in files_to_delete:\n    try:\n        os.remove(file_path)\n        print(f&quot;{file_path} \u5df2\u6210\u529f\u5220\u9664&quot;)\n    except FileNotFoundError:\n        print(f&quot;{file_path} \u4e0d\u5b58\u5728&quot;)\n    except PermissionError:\n        print(f&quot;\u6ca1\u6709\u6743\u9650\u5220\u9664 {file_path}&quot;)\n    except Exception as e:\n        print(f&quot;\u5220\u9664\u6587\u4ef6\u65f6\u53d1\u751f\u9519\u8bef: {e}&quot;)\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u80fd\u591f\u9ad8\u6548\u5730\u5904\u7406\u591a\u4e2a\u6587\u4ef6\u7684\u5220\u9664\u64cd\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u5220\u9664\u6587\u4ef6\u53ef\u4ee5\u4f7f\u7528os\u6a21\u5757\u4e2d\u7684remove()\u51fd\u6570\u3001\u901a\u8fc7\u5f02\u5e38\u5904\u7406\u6765\u786e\u4fdd\u6587\u4ef6\u5220\u9664\u7684\u5b89\u5168\u6027\u3001\u4f7f\u7528pa [&hellip;]","protected":false},"author":3,"featured_media":976919,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/976914"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=976914"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/976914\/revisions"}],"predecessor-version":[{"id":976922,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/976914\/revisions\/976922"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/976919"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=976914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=976914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=976914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}