{"id":1060945,"date":"2024-12-31T15:38:29","date_gmt":"2024-12-31T07:38:29","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1060945.html"},"modified":"2024-12-31T15:38:32","modified_gmt":"2024-12-31T07:38:32","slug":"python%e5%a6%82%e4%bd%95%e8%8e%b7%e5%8f%96%e6%96%87%e4%bb%b6%e7%9a%84%e6%96%87%e4%bb%b6%e5%90%8d","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1060945.html","title":{"rendered":"python\u5982\u4f55\u83b7\u53d6\u6587\u4ef6\u7684\u6587\u4ef6\u540d"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/569fc8d2-397d-441d-b6d8-e14583596428.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u5982\u4f55\u83b7\u53d6\u6587\u4ef6\u7684\u6587\u4ef6\u540d\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u83b7\u53d6\u6587\u4ef6\u7684\u6587\u4ef6\u540d\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f7f\u7528os\u6a21\u5757\u3001os.path\u6a21\u5757\u548cpathlib\u6a21\u5757\u3002<\/strong> \u5176\u4e2d<strong>os.path\u6a21\u5757<\/strong>\u662f\u6700\u5e38\u7528\u7684\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5904\u7406\u8def\u5f84\u548c\u6587\u4ef6\u540d\u7684\u5404\u79cd\u64cd\u4f5c\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u53ef\u4ee5\u4f7f\u7528os.path.basename\u3001os.path.split\u548cpathlib.Path\u7b49\u65b9\u6cd5\u6765\u83b7\u53d6\u6587\u4ef6\u7684\u6587\u4ef6\u540d\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u65b9\u6cd5\u7684\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528os.path\u6a21\u5757<\/p>\n<\/p>\n<p><p>os.path\u6a21\u5757\u662fPython\u7684\u6807\u51c6\u5e93\u4e4b\u4e00\uff0c\u4e13\u95e8\u7528\u4e8e\u64cd\u4f5c\u6587\u4ef6\u8def\u5f84\u3002os.path.basename\u662f\u83b7\u53d6\u6587\u4ef6\u540d\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u4f7f\u7528os.path.basename<\/h3>\n<\/p>\n<p><p>os.path.basename\u65b9\u6cd5\u53ef\u4ee5\u76f4\u63a5\u83b7\u53d6\u6587\u4ef6\u7684\u6587\u4ef6\u540d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>file_path = &quot;\/path\/to\/your\/file.txt&quot;<\/p>\n<p>file_name = os.path.basename(file_path)<\/p>\n<p>print(file_name)  # \u8f93\u51fa\uff1afile.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cos.path.basename\u65b9\u6cd5\u4f1a\u8fd4\u56de\u8def\u5f84\u7684\u6700\u540e\u4e00\u4e2a\u7ec4\u6210\u90e8\u5206\uff0c\u5373\u6587\u4ef6\u540d\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u4f7f\u7528os.path.split<\/h3>\n<\/p>\n<p><p>os.path.split\u65b9\u6cd5\u53ef\u4ee5\u5c06\u8def\u5f84\u5206\u5272\u6210\u76ee\u5f55\u548c\u6587\u4ef6\u540d\u4e24\u90e8\u5206\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>file_path = &quot;\/path\/to\/your\/file.txt&quot;<\/p>\n<p>dir_name, file_name = os.path.split(file_path)<\/p>\n<p>print(file_name)  # \u8f93\u51fa\uff1afile.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>os.path.split\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u5143\u7ec4\uff0c\u7b2c\u4e00\u4e2a\u5143\u7d20\u662f\u76ee\u5f55\u540d\uff0c\u7b2c\u4e8c\u4e2a\u5143\u7d20\u662f\u6587\u4ef6\u540d\u3002\u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u5730\u540c\u65f6\u83b7\u53d6\u76ee\u5f55\u540d\u548c\u6587\u4ef6\u540d\u3002<\/p>\n<\/p>\n<p><h3>3\u3001\u4f7f\u7528os.path.splitext<\/h3>\n<\/p>\n<p><p>os.path.splitext\u65b9\u6cd5\u53ef\u4ee5\u5c06\u6587\u4ef6\u8def\u5f84\u5206\u5272\u6210\u6587\u4ef6\u540d\u548c\u6587\u4ef6\u6269\u5c55\u540d\u4e24\u90e8\u5206\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>file_path = &quot;\/path\/to\/your\/file.txt&quot;<\/p>\n<p>file_name, file_extension = os.path.splitext(os.path.basename(file_path))<\/p>\n<p>print(file_name)  # \u8f93\u51fa\uff1afile<\/p>\n<p>print(file_extension)  # \u8f93\u51fa\uff1a.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>os.path.splitext\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u5143\u7ec4\uff0c\u7b2c\u4e00\u4e2a\u5143\u7d20\u662f\u6587\u4ef6\u540d\uff0c\u7b2c\u4e8c\u4e2a\u5143\u7d20\u662f\u6587\u4ef6\u6269\u5c55\u540d\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528pathlib\u6a21\u5757<\/p>\n<\/p>\n<p><p>pathlib\u6a21\u5757\u662fPython 3.4\u5f15\u5165\u7684\u65b0\u6a21\u5757\uff0c\u7528\u4e8e\u64cd\u4f5c\u8def\u5f84\u548c\u6587\u4ef6\u3002\u76f8\u6bd4\u4e8eos.path\u6a21\u5757\uff0cpathlib\u6a21\u5757\u66f4\u52a0\u9762\u5411\u5bf9\u8c61\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u4f7f\u7528Path\u5bf9\u8c61<\/h3>\n<\/p>\n<p><p>pathlib.Path\u5bf9\u8c61\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u6d01\u7684\u65b9\u5f0f\u6765\u83b7\u53d6\u6587\u4ef6\u540d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pathlib import Path<\/p>\n<p>file_path = Path(&quot;\/path\/to\/your\/file.txt&quot;)<\/p>\n<p>file_name = file_path.name<\/p>\n<p>print(file_name)  # \u8f93\u51fa\uff1afile.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cfile_path\u662f\u4e00\u4e2aPath\u5bf9\u8c61\uff0cfile_path.name\u5c5e\u6027\u8fd4\u56de\u6587\u4ef6\u540d\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u83b7\u53d6\u6587\u4ef6\u540d\u548c\u6269\u5c55\u540d<\/h3>\n<\/p>\n<p><p>pathlib\u6a21\u5757\u4e5f\u63d0\u4f9b\u4e86\u83b7\u53d6\u6587\u4ef6\u540d\u548c\u6269\u5c55\u540d\u7684\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pathlib import Path<\/p>\n<p>file_path = Path(&quot;\/path\/to\/your\/file.txt&quot;)<\/p>\n<p>file_stem = file_path.stem<\/p>\n<p>file_extension = file_path.suffix<\/p>\n<p>print(file_stem)  # \u8f93\u51fa\uff1afile<\/p>\n<p>print(file_extension)  # \u8f93\u51fa\uff1a.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cfile_path.stem\u5c5e\u6027\u8fd4\u56de\u6587\u4ef6\u540d\u90e8\u5206\uff0cfile_path.suffix\u5c5e\u6027\u8fd4\u56de\u6587\u4ef6\u6269\u5c55\u540d\u90e8\u5206\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u7ed3\u5408\u4f7f\u7528os\u548cpathlib\u6a21\u5757<\/p>\n<\/p>\n<p><p>\u6709\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u7ed3\u5408\u4f7f\u7528os\u6a21\u5757\u548cpathlib\u6a21\u5757\u6765\u5904\u7406\u8def\u5f84\u548c\u6587\u4ef6\u540d\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u83b7\u53d6\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84\u548c\u6587\u4ef6\u540d<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>from pathlib import Path<\/p>\n<p>file_path = &quot;\/path\/to\/your\/file.txt&quot;<\/p>\n<p>absolute_path = os.path.abspath(file_path)<\/p>\n<p>file_name = Path(absolute_path).name<\/p>\n<p>print(absolute_path)  # \u8f93\u51fa\uff1a\/path\/to\/your\/file.txt<\/p>\n<p>print(file_name)  # \u8f93\u51fa\uff1afile.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cos.path.abspath\u65b9\u6cd5\u7528\u4e8e\u83b7\u53d6\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84\uff0cPath\u5bf9\u8c61\u7528\u4e8e\u83b7\u53d6\u6587\u4ef6\u540d\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u5904\u7406\u6587\u4ef6\u8def\u5f84\u7684\u517c\u5bb9\u6027<\/h3>\n<\/p>\n<p><p>\u5728\u8de8\u5e73\u53f0\u5f00\u53d1\u4e2d\uff0c\u5904\u7406\u6587\u4ef6\u8def\u5f84\u7684\u517c\u5bb9\u6027\u975e\u5e38\u91cd\u8981\u3002os.path\u6a21\u5757\u548cpathlib\u6a21\u5757\u90fd\u63d0\u4f9b\u4e86\u5904\u7406\u8def\u5f84\u5206\u9694\u7b26\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>from pathlib import Path<\/p>\n<p>file_path = os.path.join(&quot;path&quot;, &quot;to&quot;, &quot;your&quot;, &quot;file.txt&quot;)<\/p>\n<p>file_name = Path(file_path).name<\/p>\n<p>print(file_path)  # \u8f93\u51fa\uff1apath\/to\/your\/file.txt \u6216 path\\to\\your\\file.txt<\/p>\n<p>print(file_name)  # \u8f93\u51fa\uff1afile.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cos.path.join\u65b9\u6cd5\u7528\u4e8e\u62fc\u63a5\u8def\u5f84\uff0c\u786e\u4fdd\u8def\u5f84\u5206\u9694\u7b26\u7684\u517c\u5bb9\u6027\uff0cPath\u5bf9\u8c61\u7528\u4e8e\u83b7\u53d6\u6587\u4ef6\u540d\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u5b9e\u9645\u5e94\u7528\u573a\u666f<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u83b7\u53d6\u6587\u4ef6\u540d\u901a\u5e38\u7528\u4e8e\u65e5\u5fd7\u8bb0\u5f55\u3001\u6587\u4ef6\u5904\u7406\u548c\u8def\u5f84\u7ba1\u7406\u7b49\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u65e5\u5fd7\u8bb0\u5f55<\/h3>\n<\/p>\n<p><p>\u5728\u65e5\u5fd7\u8bb0\u5f55\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u8bb0\u5f55\u5f53\u524d\u811a\u672c\u7684\u6587\u4ef6\u540d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>def log_message(message):<\/p>\n<p>    current_file = os.path.basename(__file__)<\/p>\n<p>    print(f&quot;[{current_file}] {message}&quot;)<\/p>\n<p>log_message(&quot;This is a log message.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cos.path.basename(<strong>file<\/strong>)\u7528\u4e8e\u83b7\u53d6\u5f53\u524d\u811a\u672c\u7684\u6587\u4ef6\u540d\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u6587\u4ef6\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u5728\u6587\u4ef6\u5904\u7406\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u6839\u636e\u6587\u4ef6\u540d\u6765\u8fdb\u884c\u4e0d\u540c\u7684\u64cd\u4f5c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>def process_file(file_path):<\/p>\n<p>    file_name, file_extension = os.path.splitext(os.path.basename(file_path))<\/p>\n<p>    if file_extension == &quot;.txt&quot;:<\/p>\n<p>        print(f&quot;Processing text file: {file_name}&quot;)<\/p>\n<p>    elif file_extension == &quot;.csv&quot;:<\/p>\n<p>        print(f&quot;Processing CSV file: {file_name}&quot;)<\/p>\n<p>    else:<\/p>\n<p>        print(f&quot;Unknown file type: {file_name}&quot;)<\/p>\n<p>process_file(&quot;\/path\/to\/your\/file.txt&quot;)<\/p>\n<p>process_file(&quot;\/path\/to\/your\/file.csv&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cos.path.splitext\u7528\u4e8e\u83b7\u53d6\u6587\u4ef6\u540d\u548c\u6587\u4ef6\u6269\u5c55\u540d\uff0c\u6839\u636e\u6587\u4ef6\u6269\u5c55\u540d\u8fdb\u884c\u4e0d\u540c\u7684\u5904\u7406\u3002<\/p>\n<\/p>\n<p><h3>3\u3001\u8def\u5f84\u7ba1\u7406<\/h3>\n<\/p>\n<p><p>\u5728\u8def\u5f84\u7ba1\u7406\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u52a8\u6001\u751f\u6210\u6587\u4ef6\u8def\u5f84\u548c\u6587\u4ef6\u540d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>def generate_file_path(directory, file_name, extension):<\/p>\n<p>    return os.path.join(directory, f&quot;{file_name}.{extension}&quot;)<\/p>\n<p>file_path = generate_file_path(&quot;\/path\/to\/your&quot;, &quot;file&quot;, &quot;txt&quot;)<\/p>\n<p>print(file_path)  # \u8f93\u51fa\uff1a\/path\/to\/your\/file.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cos.path.join\u7528\u4e8e\u751f\u6210\u6587\u4ef6\u8def\u5f84\uff0c\u786e\u4fdd\u8def\u5f84\u5206\u9694\u7b26\u7684\u517c\u5bb9\u6027\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\u83b7\u53d6\u6587\u4ef6\u7684\u6587\u4ef6\u540d\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f7f\u7528os\u6a21\u5757\u3001os.path\u6a21\u5757\u548cpathlib\u6a21\u5757\u3002<strong>os.path.basename\u65b9\u6cd5\u662f\u6700\u5e38\u7528\u7684\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u76f4\u63a5\u83b7\u53d6\u6587\u4ef6\u540d\u3002<\/strong> \u53e6\u5916\uff0cos.path.split\u548cos.path.splitext\u65b9\u6cd5\u4e5f\u975e\u5e38\u5b9e\u7528\uff0c\u53ef\u4ee5\u5206\u522b\u83b7\u53d6\u76ee\u5f55\u540d\u548c\u6587\u4ef6\u6269\u5c55\u540d\u3002pathlib\u6a21\u5757\u63d0\u4f9b\u4e86\u66f4\u52a0\u9762\u5411\u5bf9\u8c61\u7684\u65b9\u5f0f\u6765\u64cd\u4f5c\u8def\u5f84\u548c\u6587\u4ef6\uff0c\u63a8\u8350\u5728Python 3.4\u53ca\u4ee5\u4e0a\u7248\u672c\u4e2d\u4f7f\u7528\u3002\u7ed3\u5408\u4f7f\u7528os\u6a21\u5757\u548cpathlib\u6a21\u5757\uff0c\u53ef\u4ee5\u5904\u7406\u66f4\u591a\u590d\u6742\u7684\u8def\u5f84\u548c\u6587\u4ef6\u540d\u64cd\u4f5c\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u83b7\u53d6\u6587\u4ef6\u540d\u901a\u5e38\u7528\u4e8e\u65e5\u5fd7\u8bb0\u5f55\u3001\u6587\u4ef6\u5904\u7406\u548c\u8def\u5f84\u7ba1\u7406\u7b49\u573a\u666f\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u548c\u4f7f\u7528Python\u4e2d\u7684\u6587\u4ef6\u540d\u83b7\u53d6\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u63d0\u53d6\u6587\u4ef6\u540d\u800c\u4e0d\u5305\u542b\u8def\u5f84\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>os.path<\/code>\u6a21\u5757\u4e2d\u7684<code>basename<\/code>\u51fd\u6570\u6765\u63d0\u53d6\u6587\u4ef6\u540d\u800c\u4e0d\u5305\u542b\u8def\u5f84\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;\nfile_name = os.path.basename(file_path)\nprint(file_name)  # \u8f93\u51fa\uff1afile.txt\n<\/code><\/pre>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u5c06\u8f93\u51fa\u6307\u5b9a\u8def\u5f84\u7684\u6587\u4ef6\u540d\uff0c\u4ec5\u5305\u542b\u6587\u4ef6\u7684\u540d\u79f0\u548c\u6269\u5c55\u540d\u3002<\/p>\n<p><strong>Python\u4e2d\u6709\u54ea\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u83b7\u53d6\u6587\u4ef6\u7684\u6269\u5c55\u540d\uff1f<\/strong><br \/>\u53ef\u4ee5\u4f7f\u7528<code>os.path<\/code>\u6a21\u5757\u4e2d\u7684<code>splitext<\/code>\u51fd\u6570\u6765\u83b7\u53d6\u6587\u4ef6\u7684\u6269\u5c55\u540d\u3002\u793a\u4f8b\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">import os\n\nfile_path = &#39;\/path\/to\/your\/file.txt&#39;\nfile_name, file_extension = os.path.splitext(file_path)\nprint(file_extension)  # \u8f93\u51fa\uff1a.txt\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u4ec5\u53ef\u4ee5\u83b7\u53d6\u6587\u4ef6\u540d\uff0c\u8fd8\u53ef\u4ee5\u540c\u65f6\u83b7\u53d6\u6587\u4ef6\u7684\u6269\u5c55\u540d\u3002<\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528Pathlib\u83b7\u53d6\u6587\u4ef6\u540d\u548c\u6269\u5c55\u540d\uff1f<\/strong><br \/>\u4f7f\u7528<code>pathlib<\/code>\u6a21\u5757\u53ef\u4ee5\u66f4\u4e3a\u76f4\u89c2\u5730\u5904\u7406\u6587\u4ef6\u8def\u5f84\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a  <\/p>\n<pre><code class=\"language-python\">from pathlib import Path\n\nfile_path = Path(&#39;\/path\/to\/your\/file.txt&#39;)\nfile_name = file_path.name\nfile_extension = file_path.suffix\nprint(file_name)      # \u8f93\u51fa\uff1afile.txt\nprint(file_extension) # \u8f93\u51fa\uff1a.txt\n<\/code><\/pre>\n<p><code>Pathlib<\/code>\u4e3a\u6587\u4ef6\u548c\u8def\u5f84\u64cd\u4f5c\u63d0\u4f9b\u4e86\u9762\u5411\u5bf9\u8c61\u7684\u65b9\u5f0f\uff0c\u9002\u5408\u4e8e\u73b0\u4ee3Python\u7f16\u7a0b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u83b7\u53d6\u6587\u4ef6\u7684\u6587\u4ef6\u540d\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f7f\u7528os\u6a21\u5757\u3001os.path\u6a21\u5757\u548cpathlib\u6a21\u5757\u3002 \u5176\u4e2do [&hellip;]","protected":false},"author":3,"featured_media":1060953,"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\/1060945"}],"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=1060945"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1060945\/revisions"}],"predecessor-version":[{"id":1060957,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1060945\/revisions\/1060957"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1060953"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1060945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1060945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1060945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}