{"id":927855,"date":"2024-12-26T16:21:17","date_gmt":"2024-12-26T08:21:17","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/927855.html"},"modified":"2024-12-26T16:21:21","modified_gmt":"2024-12-26T08:21:21","slug":"python%e5%a6%82%e4%bd%95%e6%94%b9%e5%8f%98path","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/927855.html","title":{"rendered":"python\u5982\u4f55\u6539\u53d8path"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25063819\/128beb0e-3073-4ec3-b8ce-313485894332.webp\" alt=\"python\u5982\u4f55\u6539\u53d8path\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u6539\u53d8\u8def\u5f84\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\uff1a\u4f7f\u7528<code>os<\/code>\u6a21\u5757\u4e2d\u7684<code>chdir<\/code>\u51fd\u6570\u3001\u4f7f\u7528<code>sys<\/code>\u6a21\u5757\u4fee\u6539<code>sys.path<\/code>\u3001\u5728\u811a\u672c\u4e2d\u4e34\u65f6\u6dfb\u52a0\u8def\u5f84\u3002<\/strong>\u901a\u8fc7\u4f7f\u7528<code>os.chdir()<\/code>\u51fd\u6570\uff0c\u4f60\u53ef\u4ee5\u5728\u811a\u672c\u4e2d\u6539\u53d8\u5f53\u524d\u7684\u5de5\u4f5c\u76ee\u5f55\uff1b\u901a\u8fc7\u4fee\u6539<code>sys.path<\/code>\uff0c\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u52a8\u6001\u5730\u6539\u53d8Python\u7684\u6a21\u5757\u641c\u7d22\u8def\u5f84\uff0c\u4ece\u800c\u5bfc\u5165\u4e0d\u540c\u76ee\u5f55\u4e0b\u7684\u6a21\u5757\uff1b\u6b64\u5916\uff0c\u4e5f\u53ef\u4ee5\u5728\u811a\u672c\u4e2d\u4e34\u65f6\u6dfb\u52a0\u8def\u5f84\u4ee5\u4f9b\u6a21\u5757\u5bfc\u5165\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528<code>os<\/code>\u6a21\u5757\u6539\u53d8\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55<\/h3>\n<\/p>\n<p><p><code>os<\/code>\u6a21\u5757\u662fPython\u7684\u6807\u51c6\u5e93\u4e4b\u4e00\uff0c\u5b83\u63d0\u4f9b\u4e86\u8bb8\u591a\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u4ea4\u4e92\u7684\u529f\u80fd\u3002\u5176\u4e2d\uff0c<code>os.chdir()<\/code>\u51fd\u6570\u53ef\u4ee5\u7528\u6765\u6539\u53d8\u5f53\u524d\u7684\u5de5\u4f5c\u76ee\u5f55\u3002<\/p>\n<\/p>\n<p><h4>1. <code>os.chdir()<\/code>\u51fd\u6570<\/h4>\n<\/p>\n<p><p><code>os.chdir(path)<\/code>\u51fd\u6570\u7528\u4e8e\u6539\u53d8\u5f53\u524d\u7684\u5de5\u4f5c\u76ee\u5f55\u4e3a\u6307\u5b9a\u7684\u8def\u5f84<code>path<\/code>\u3002\u8fd9\u5728\u9700\u8981\u5bf9\u4e0d\u540c\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u8fdb\u884c\u64cd\u4f5c\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<h2><strong>\u67e5\u770b\u5f53\u524d\u7684\u5de5\u4f5c\u76ee\u5f55<\/strong><\/h2>\n<p>current_directory = os.getcwd()<\/p>\n<p>print(&quot;\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55:&quot;, current_directory)<\/p>\n<h2><strong>\u6539\u53d8\u5de5\u4f5c\u76ee\u5f55<\/strong><\/h2>\n<p>os.chdir(&#39;\/path\/to\/new\/directory&#39;)<\/p>\n<h2><strong>\u9a8c\u8bc1\u5de5\u4f5c\u76ee\u5f55\u7684\u6539\u53d8<\/strong><\/h2>\n<p>new_directory = os.getcwd()<\/p>\n<p>print(&quot;\u65b0\u7684\u5de5\u4f5c\u76ee\u5f55:&quot;, new_directory)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u4f7f\u7528\u7edd\u5bf9\u8def\u5f84\u548c\u76f8\u5bf9\u8def\u5f84<\/h4>\n<\/p>\n<p><p>\u5728\u4f7f\u7528<code>os.chdir()<\/code>\u65f6\uff0c\u53ef\u4ee5\u4f20\u5165\u7edd\u5bf9\u8def\u5f84\u6216\u76f8\u5bf9\u8def\u5f84\u3002\u7edd\u5bf9\u8def\u5f84\u662f\u4ece\u6839\u76ee\u5f55\u5f00\u59cb\u7684\u5b8c\u6574\u8def\u5f84\uff0c\u800c\u76f8\u5bf9\u8def\u5f84\u662f\u57fa\u4e8e\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u7684\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528\u7edd\u5bf9\u8def\u5f84<\/p>\n<p>os.chdir(&#39;\/Users\/username\/Documents&#39;)<\/p>\n<h2><strong>\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84<\/strong><\/h2>\n<p>os.chdir(&#39;..\/another_directory&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528<code>sys<\/code>\u6a21\u5757\u4fee\u6539<code>sys.path<\/code><\/h3>\n<\/p>\n<p><p><code>sys<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u4e00\u4e9b\u4e0ePython\u89e3\u91ca\u5668\u76f8\u5173\u7684\u529f\u80fd\uff0c\u5176\u4e2d<code>sys.path<\/code>\u662f\u4e00\u4e2a\u5217\u8868\uff0c\u5305\u542b\u4e86Python\u89e3\u91ca\u5668\u5728\u5bfc\u5165\u6a21\u5757\u65f6\u641c\u7d22\u7684\u8def\u5f84\u3002\u901a\u8fc7\u4fee\u6539<code>sys.path<\/code>\uff0c\u53ef\u4ee5\u52a8\u6001\u5730\u6539\u53d8\u6a21\u5757\u7684\u641c\u7d22\u8def\u5f84\u3002<\/p>\n<\/p>\n<p><h4>1. \u4fee\u6539<code>sys.path<\/code><\/h4>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u901a\u8fc7\u5728<code>sys.path<\/code>\u4e2d\u6dfb\u52a0\u65b0\u7684\u8def\u5f84\uff0c\u4f7f\u5f97Python\u80fd\u591f\u5728\u6307\u5b9a\u7684\u76ee\u5f55\u4e2d\u67e5\u627e\u6a21\u5757\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<h2><strong>\u6253\u5370\u9ed8\u8ba4\u7684sys.path<\/strong><\/h2>\n<p>print(&quot;\u9ed8\u8ba4\u7684sys.path:&quot;, sys.path)<\/p>\n<h2><strong>\u6dfb\u52a0\u65b0\u7684\u8def\u5f84\u5230sys.path<\/strong><\/h2>\n<p>sys.path.append(&#39;\/path\/to\/module\/directory&#39;)<\/p>\n<h2><strong>\u9a8c\u8bc1\u8def\u5f84\u662f\u5426\u88ab\u6dfb\u52a0<\/strong><\/h2>\n<p>print(&quot;\u4fee\u6539\u540e\u7684sys.path:&quot;, sys.path)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u4f7f\u7528<code>sys.path.insert()<\/code><\/h4>\n<\/p>\n<p><p>\u4e0e<code>append()<\/code>\u4e0d\u540c\uff0c<code>insert()<\/code>\u65b9\u6cd5\u5141\u8bb8\u4f60\u5728<code>sys.path<\/code>\u7684\u7279\u5b9a\u4f4d\u7f6e\u63d2\u5165\u8def\u5f84\u3002\u901a\u5e38\u5728\u7d22\u5f150\u5904\u63d2\u5165\u65b0\u8def\u5f84\uff0c\u4ee5\u4f18\u5148\u641c\u7d22\u8be5\u76ee\u5f55\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u5728sys.path\u7684\u5f00\u5934\u63d2\u5165\u65b0\u8def\u5f84<\/p>\n<p>sys.path.insert(0, &#39;\/path\/to\/priority\/module\/directory&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u5728\u811a\u672c\u4e2d\u4e34\u65f6\u6dfb\u52a0\u8def\u5f84<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\uff0c\u4f60\u53ef\u80fd\u4e0d\u60f3\u6c38\u4e45\u4fee\u6539<code>sys.path<\/code>\uff0c\u800c\u53ea\u662f\u60f3\u5728\u811a\u672c\u6267\u884c\u671f\u95f4\u4e34\u65f6\u6dfb\u52a0\u4e00\u4e2a\u8def\u5f84\u3002\u53ef\u4ee5\u4f7f\u7528<code>contextlib<\/code>\u6a21\u5757\u7684<code>contextmanager<\/code>\u88c5\u9970\u5668\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528<code>contextlib.contextmanager<\/code><\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\u6765\u4e34\u65f6\u6539\u53d8<code>sys.path<\/code>\uff0c\u5728\u4ee3\u7801\u5757\u6267\u884c\u5b8c\u6bd5\u540e\u81ea\u52a8\u6062\u590d\u539f\u59cb\u72b6\u6001\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>from contextlib import contextmanager<\/p>\n<p>@contextmanager<\/p>\n<p>def add_path(temp_path):<\/p>\n<p>    original_sys_path = sys.path.copy()<\/p>\n<p>    sys.path.append(temp_path)<\/p>\n<p>    try:<\/p>\n<p>        yield<\/p>\n<p>    finally:<\/p>\n<p>        sys.path = original_sys_path<\/p>\n<h2><strong>\u4f7f\u7528\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\u4e34\u65f6\u6dfb\u52a0\u8def\u5f84<\/strong><\/h2>\n<p>with add_path(&#39;\/path\/to\/temporary\/module\/directory&#39;):<\/p>\n<p>    # \u5728\u8fd9\u91cc\u5bfc\u5165\u6a21\u5757\u6216\u6267\u884c\u4ee3\u7801<\/p>\n<p>    pass<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u4f7f\u7528\u4e34\u65f6\u8def\u5f84<\/h4>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7279\u522b\u9002\u5408\u5728\u9700\u8981\u4e34\u65f6\u6539\u53d8\u6a21\u5757\u641c\u7d22\u8def\u5f84\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\uff0c\u6bd4\u5982\u5728\u6d4b\u8bd5\u73af\u5883\u4e2d\u5bfc\u5165\u4e0d\u540c\u7248\u672c\u7684\u6a21\u5757\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u52a8\u6001\u5bfc\u5165\u6a21\u5757<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u6539\u53d8\u8def\u5f84\u5916\uff0c\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528<code>importlib<\/code>\u6a21\u5757\u52a8\u6001\u5bfc\u5165\u6a21\u5757\uff0c\u8fd9\u5728\u9700\u8981\u5728\u8fd0\u884c\u65f6\u51b3\u5b9a\u5bfc\u5165\u54ea\u4e2a\u6a21\u5757\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528<code>importlib.import_module()<\/code><\/h4>\n<\/p>\n<p><p><code>importlib<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86<code>import_module()<\/code>\u51fd\u6570\uff0c\u53ef\u4ee5\u901a\u8fc7\u6a21\u5757\u7684\u540d\u79f0\u5b57\u7b26\u4e32\u52a8\u6001\u5bfc\u5165\u6a21\u5757\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import importlib<\/p>\n<h2><strong>\u52a8\u6001\u5bfc\u5165\u6a21\u5757<\/strong><\/h2>\n<p>module_name = &#39;os&#39;<\/p>\n<p>os_module = importlib.import_module(module_name)<\/p>\n<h2><strong>\u4f7f\u7528\u5bfc\u5165\u7684\u6a21\u5757<\/strong><\/h2>\n<p>print(os_module.getcwd())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u5e94\u7528\u573a\u666f<\/h4>\n<\/p>\n<p><p>\u52a8\u6001\u5bfc\u5165\u6a21\u5757\u7684\u4f18\u52bf\u5728\u4e8e\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u6839\u636e\u6761\u4ef6\u51b3\u5b9a\u5bfc\u5165\u54ea\u4e2a\u6a21\u5757\uff0c\u6bd4\u5982\u6839\u636e\u7528\u6237\u8f93\u5165\u6216\u914d\u7f6e\u6587\u4ef6\u7684\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u603b\u7ed3\u4e0e\u6700\u4f73\u5b9e\u8df5<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\u6539\u53d8\u8def\u5f84\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u5e94\u7528\u573a\u666f\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u4f7f\u7528<code>os.chdir()<\/code><\/strong>\uff1a\u9002\u7528\u4e8e\u9700\u8981\u6539\u53d8\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u7684\u573a\u666f\uff0c\u7279\u522b\u662f\u5728\u6587\u4ef6\u64cd\u4f5c\u65f6\u3002<\/li>\n<li><strong>\u4fee\u6539<code>sys.path<\/code><\/strong>\uff1a\u9002\u7528\u4e8e\u9700\u8981\u52a8\u6001\u6539\u53d8\u6a21\u5757\u641c\u7d22\u8def\u5f84\uff0c\u5bfc\u5165\u975e\u6807\u51c6\u76ee\u5f55\u4e0b\u7684\u6a21\u5757\u3002<\/li>\n<li><strong>\u4f7f\u7528\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\u4e34\u65f6\u6dfb\u52a0\u8def\u5f84<\/strong>\uff1a\u9002\u5408\u5728\u811a\u672c\u8fd0\u884c\u671f\u95f4\u4e34\u65f6\u6539\u53d8\u8def\u5f84\u3002<\/li>\n<li><strong>\u52a8\u6001\u5bfc\u5165\u6a21\u5757<\/strong>\uff1a\u5728\u9700\u8981\u8fd0\u884c\u65f6\u51b3\u5b9a\u5bfc\u5165\u54ea\u4e2a\u6a21\u5757\u65f6\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u5e94\u8be5\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u5b89\u5168\u6027<\/strong>\uff1a\u907f\u514d\u5728<code>sys.path<\/code>\u4e2d\u6dfb\u52a0\u4e0d\u53d7\u4fe1\u4efb\u7684\u76ee\u5f55\uff0c\u4ee5\u9632\u6b62\u5bfc\u5165\u6076\u610f\u6a21\u5757\u3002<\/li>\n<li><strong>\u53ef\u7ef4\u62a4\u6027<\/strong>\uff1a\u5c3d\u91cf\u51cf\u5c11\u5bf9<code>sys.path<\/code>\u7684\u76f4\u63a5\u4fee\u6539\uff0c\u4f7f\u7528\u4e0a\u4e0b\u6587\u7ba1\u7406\u5668\u6216\u914d\u7f6e\u6587\u4ef6\u7ba1\u7406\u8def\u5f84\u3002<\/li>\n<li><strong>\u517c\u5bb9\u6027<\/strong>\uff1a\u6ce8\u610f\u8de8\u5e73\u53f0\u8def\u5f84\u683c\u5f0f\u7684\u5dee\u5f02\uff0c\u5c3d\u91cf\u4f7f\u7528<code>os.path.join()<\/code>\u7b49\u51fd\u6570\u6784\u5efa\u8def\u5f84\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u5bf9\u8fd9\u4e9b\u65b9\u6cd5\u7684\u7075\u6d3b\u8fd0\u7528\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u7ba1\u7406\u548c\u6539\u53d8Python\u7684\u8def\u5f84\u8bbe\u7f6e\uff0c\u4e3a\u5f00\u53d1\u5de5\u4f5c\u63d0\u4f9b\u4fbf\u5229\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u6dfb\u52a0\u65b0\u7684\u8def\u5f84\u5230sys.path\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539<code>sys.path<\/code>\u5217\u8868\u6765\u6dfb\u52a0\u65b0\u7684\u6a21\u5757\u641c\u7d22\u8def\u5f84\u3002\u9996\u5148\uff0c\u9700\u8981\u5bfc\u5165<code>sys<\/code>\u6a21\u5757\uff0c\u7136\u540e\u4f7f\u7528<code>sys.path.append(&#39;\u65b0\u8def\u5f84&#39;)<\/code>\u6216<code>sys.path.insert(0, &#39;\u65b0\u8def\u5f84&#39;)<\/code>\u5c06\u65b0\u7684\u8def\u5f84\u6dfb\u52a0\u5230\u641c\u7d22\u8def\u5f84\u4e2d\u3002<code>append<\/code>\u65b9\u6cd5\u4f1a\u5c06\u8def\u5f84\u6dfb\u52a0\u5230\u5217\u8868\u7684\u672b\u5c3e\uff0c\u800c<code>insert<\/code>\u65b9\u6cd5\u5219\u5c06\u5176\u6dfb\u52a0\u5230\u5217\u8868\u7684\u5f00\u5934\uff0c\u4ece\u800c\u4f18\u5148\u641c\u7d22\u65b0\u8def\u5f84\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u6c38\u4e45\u6027\u5730\u4fee\u6539\u6a21\u5757\u641c\u7d22\u8def\u5f84\uff1f<\/strong><br \/>\u8981\u6c38\u4e45\u6027\u5730\u4fee\u6539Python\u7684\u6a21\u5757\u641c\u7d22\u8def\u5f84\uff0c\u53ef\u4ee5\u8003\u8651\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u3002\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u7cfb\u7edf\u5c5e\u6027\u4e2d\u7684\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e<code>PYTHONPATH<\/code>\u53d8\u91cf\uff0c\u800c\u5728Linux\u6216macOS\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u5728\u7528\u6237\u7684<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u6587\u4ef6\u4e2d\u6dfb\u52a0<code>export PYTHONPATH=&quot;\/\u4f60\u7684\u8def\u5f84&quot;<\/code>\u3002\u8fd9\u6837\uff0c\u542f\u52a8Python\u65f6\u4f1a\u81ea\u52a8\u52a0\u8f7d\u8fd9\u4e9b\u8def\u5f84\u3002<\/p>\n<p><strong>\u5982\u679c\u6dfb\u52a0\u7684\u8def\u5f84\u5305\u542b\u591a\u4e2a\u76ee\u5f55\uff0c\u5e94\u8be5\u5982\u4f55\u5904\u7406\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u5982\u679c\u9700\u8981\u6dfb\u52a0\u591a\u4e2a\u76ee\u5f55\u5230\u6a21\u5757\u641c\u7d22\u8def\u5f84\uff0c\u53ef\u4ee5\u5c06\u5b83\u4eec\u4ee5\u5206\u53f7\uff08Windows\uff09\u6216\u5192\u53f7\uff08Linux\/macOS\uff09\u5206\u9694\u5f00\uff0c\u6216\u9010\u4e2a\u4f7f\u7528<code>sys.path.append()<\/code>\u6dfb\u52a0\u6bcf\u4e2a\u76ee\u5f55\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u5217\u8868\u5b58\u653e\u6240\u6709\u8def\u5f84\uff0c\u7136\u540e\u904d\u5386\u8fd9\u4e2a\u5217\u8868\uff0c\u5c06\u6bcf\u4e2a\u8def\u5f84\u6dfb\u52a0\u5230<code>sys.path<\/code>\u4e2d\u3002\u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406\u591a\u4e2a\u8def\u5f84\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u7ef4\u62a4\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u6539\u53d8\u8def\u5f84\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\uff1a\u4f7f\u7528os\u6a21\u5757\u4e2d\u7684chdir\u51fd\u6570\u3001\u4f7f\u7528sys\u6a21\u5757\u4fee\u6539sys.path\u3001\u5728\u811a [&hellip;]","protected":false},"author":3,"featured_media":927862,"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\/927855"}],"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=927855"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/927855\/revisions"}],"predecessor-version":[{"id":927863,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/927855\/revisions\/927863"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/927862"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=927855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=927855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=927855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}